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 } } } |