Common Java Pitfalls

Pitfall using to compare primitive wrappers objects such as Integer

Pitfall using to compare strings

Pitfall forgetting to free resources

Pitfall testing a file before attempting to open it.

Pitfall thinking of variables as objects

Pitfall memory leaks

Pitfall - Catching Throwable Exception Error or RuntimeException

Pitfall Not understanding that String is an immutable class

Pitfall - Missing a break in a switch case

Pitfall - Ignoring or squashing exceptions

Pitfall combining assignment and side-effects

Pitfall - String concatenation in a loop does not scale

Pitfall - Throwing Throwable Exception Error or RuntimeException

Pitfall concurrent modification exceptions

Pitfall - Ignoring method visibility

Pitfall Runtime.exec Process and ProcessBuilder dont understand shell syntax

Pitfall - Using new to create primitive wrapper instances is inefficient

Pitfall - Misplaced semicolons and missing braces

Pitfall incorrect use of wait notify