TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
TIOBE - Java Coding Standard
Search

Rule:  Design17Checked automatically with code checker

Synopsis:Avoid using equals() to compare against null
Language:Java
Severity Level:1
Category:Design


Description:
Inexperienced programmers sometimes confuse comparison concepts and use equals() to compare to null.
class Bar {
   void foo() {
       String x = "foo";
       if (x.equals(null)) { // bad!
        doSomething();
       }
   }
}