Monday, October 13, 2008

Top Nine Errors Java Programmers Make

* A .java source file can contain more than one class but it can contain atmost one Top level class (or interface) definition that is public and the name of the source file must be same as that of the public class (or interface).
* Static methods cannot be overridden but can be hidden if they are not final (Read about Overriding vs Hiding here).
* The objects created in the String pool are not subjected to GC until the class is unloaded by the JVM.
* Only methods or code blocks can be marked “synchronized”.
* Local classes cannot access non-final variables.
* -0.0 == 0.0 is true.
* Collection (singular) is an Interface, but Collections (plural) is a helper class.
* continue must be in a loop (e.g., for, do, while). It cannot appear in case constructs.
* Instance initializers are executed only if an object is constructed.

No comments: