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

Rule:  StringandStringBuffer5Checked automatically with code checker

Synopsis:Using equalsIgnoreCase() is cleaner than using toUpperCase/toLowerCase().equals()
Language:Java
Severity Level:4
Category:StringandStringBuffer


Description:
Using equalsIgnoreCase() is faster than using toUpperCase/toLowerCase().equals()
public class Foo {
  public boolean bar(String buz) {
    // should be buz.equalsIgnoreCase("baz")
    return buz.toUpperCase().equals("baz");
    // another unnecessary toUpperCase()
    // return buz.toUpperCase().equalsIgnoreCase("baz");
  }
 }