All pastes #571526 Raw Edit

Something

public text v1 · immutable
·published 2007-06-17 05:38 UTC
rendered paste body

Java for C++ folks
17Jun07
Edit Link

I’ve been learning Java for a while now, and I’m trying to highlight the major differences between Java and C++ in this article.
Readers are encouraged to comment on the things that I’ve missed.

   1. Each file should be named after a public class in the file
   2. Local Variables override scope in c++. It’s simply an error to do so in Java.
      eg:

      void foo() {
          int a=2;
          {
              int a;
              a = 4;
          }
      }

      Valid in C++, Invalid in Java
   3. All objects (NOT primitive types) are passed by reference. All variables in Java act like C++ aliases.
   4. Methods of the subclass *always* override superclass methods in Java. That is, All methods in Java behave simply like virtual methods in C++