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

Rule:  Design32Checked automatically with code checker

Synopsis:No need to check for null before an instanceof
Language:Java
Severity Level:4
Category:Design


Description:
No need to check for null before an instanceof; the instanceof keyword returns false when given a null argument.
class Foo {
 void bar(Object x) {
  if (x != null && x instanceof Bar) {
   // just drop the "x != null" check
  }
 }
}