Strings, just like any other Object, should be compared using the equals() method.
Using == and != compares references rather than values, and usually does not work.
if (variable == "foo") { /* ... */ }
if (variable != "foo") { /* ... */ }
if ("foo".equals(variable)) { /* ... */ } // Compliant
if (!"foo".equals(variable)) { /* ... */ } // Compliant
This rule is deprecated, use {rule:squid:S1698} instead.