Java for C++ folks
17Jun07
Edit Link
Ive been learning Java for a while now, and Im trying to highlight the major differences between Java and C++ in this article.
Readers are encouraged to comment on the things that Ive missed.
1. Each file should be named after a public class in the file
2. Local Variables override scope in c++. Its 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++