Using toLowerCase() or toUpperCase() to make case insensitive comparisons is inefficient because it requires the creation of temporary, intermediate String objects.

Noncompliant Code Example

boolean result1 = foo.toUpperCase().equals(bar);             // Noncompliant
boolean result2 = foo.equals(bar.toUpperCase());             // Noncompliant
boolean result3 = foo.toLowerCase().equals(bar.LowerCase()); // Noncompliant

Compliant Solution

boolean result = foo.equalsIgnoreCase(bar);                  // Compliant

Exceptions

No issue will be raised when a locale is specified because the result could be different from "equalsIgnoreCase". (e.g.: using the Turkish locale)

boolean result1 = foo.toUpperCase(locale).equals(bar);             // Compliant