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

Rule:  Design34Checked automatically with code checker

Synopsis:Position literals first in String comparisons
Language:Java
Severity Level:3
Category:Design


Description:
Position literals first in String comparisons - that way if the String is null you won't get a NullPointerException, it'll just return false.
class Foo {
 boolean bar(String x) {
  return x.equals("2"); // should be "2".equals(x)
 }
}