Over a million developers have joined DZone.

Top Ten Errors Java Programmers Make

DZone's Guide to

Top Ten Errors Java Programmers Make

· Java Zone
Free Resource

Bitbucket is for the code that takes us to Mars, decodes the human genome, or drives your next car. What will your code do? Get started with Bitbucket today, it's free.

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 :)

Bitbucket is the Git solution for professional teams who code with a purpose, not just as a hobby. Get started today, it's free.


Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


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

{{ parent.tldr }}

{{ parent.urlSource.name }}