Strings, just like any other ``++Object++``, should be compared using the ``++equals()++`` method. Using ``++==++`` or ``++!=++`` compares references rather than values, and usually does not work. == Noncompliant Code Example [source,text] ---- if (variable == "foo") { /* ... */ } if (variable != "foo") { /* ... */ } ---- == Compliant Solution [source,text] ---- if ("foo".equals(variable)) { /* ... */ } if (!"foo".equals(variable)) { /* ... */ } ---- == See * https://cwe.mitre.org/data/definitions/597[MITRE, CWE-597] - Use of Wrong Operator in String Comparison ifdef::env-github,rspecator-view[] ''' == Comments And Links (visible only on this page) include::comments-and-links.adoc[] endif::env-github,rspecator-view[]