Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Top Ten Errors Java Programmers Make

DZone's Guide to

Top Ten Errors Java Programmers Make

· Java Zone
Free Resource

Managing a MongoDB deployment? Take a load off and live migrate to MongoDB Atlas, the official automated service, with little to no downtime.

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

MongoDB Atlas is the easiest way to run the fastest-growing database for modern applications — no installation, setup, or configuration required. Easily live migrate an existing workload or start with 512MB of storage for free.

Topics:

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}