<p>
It is preferable to place string literals on the left-hand side of an <code>equals()</code> or <code>equalsIgnoreCase()</code> method call.
This prevents null pointer exceptions from being raised, as a string literal can never be null by definition.
</p>

<p>The following code:</p>

<pre>
String myString = null;

System.out.println("Equal? " + myString.equals("foo"));                        // Non-Compliant - will raise a NPE
System.out.println("Equal? " + (myString != null && myString.equals("foo")));  // Non-Compliant - null check could be removed
</pre>

<p>should be refactored into:</p>

<pre>
System.out.println("Equal?" + "foo".equals(myString));                         // Compliant - properly deals with the null case
</pre>