Over a million developers have joined DZone.

Top Ten Errors Java Programmers Make

· Java Zone

Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code! Brought to you in partnership with ZeroTurnaround.

I read an article (linked below) on “Top Ten Errors Java Programmers Make“. The author has mentioned the errors which even the most experienced programmers often commit or the New to Java programmers may commit in the future. Not only has he listed the errors but also given the possible solution for the same. I found the article really informative.

One can read the article here.

I would like to add some more:

  • 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.
Do you have some key points in Java to share? Add it as comments to the post :)

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}