equalsIgnoreCase() is faster than equals()

My intuition would tell me that String.equalsIgnoreCase() would be a more expensive operation than String.equals(). If you think about it you have a lot more combinations that you have to test. This is where reality diverges from intuition.

The first things that both String.equalsIgnoreCase() and String.equals() check is length, and I’m willing to bet that most strings aren’t the same length, so you’re done. The reality is that String.equalsIgnoreCase() may be faster in a lot of instances because its parameter is a String so it doesn’t need to check instance and cast before the length comparison like String.equals() who’s parameter is Object.

So don’t handicap your string comparison just because you’re worried about performance. With String.equalsIgnoreCase() you can be fast and flexible.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • del.icio.us
  • Facebook
  • Reddit
  • StumbleUpon

Tags: ,

One Response to “equalsIgnoreCase() is faster than equals()”

  1. VINCENT Says:


    PillSpot.org. Canadian Health&Care.Best quality drugs.No prescription online pharmacy.Special Internet Prices. Low price drugs. Order pills online

    Buy:Viagra Soft Tabs.Zithromax.Levitra.Cialis.VPXL.Cialis Super Active+.Viagra Super Active+.Maxaman.Propecia.Viagra Professional.Viagra.Soma.Tramadol.Super Active ED Pack.Cialis Soft Tabs.Viagra Super Force.Cialis Professional….

Leave a Reply