View RSS Feed

Java String

equalsIgnoreCase method

Rate this Entry
by , 04-26-2012 at 07:01 PM (1774 Views)
It shall be ignore in Java string comparison tests that whether strings are uppercase of lowercase. Use EqualsIgnoreCase mthods for equality so that to test the strings .
Java Code:
String string1 = "foo";
String string2 = "FOO";

// java string compare while ignoring case
if (string1.equalsIgnoreCase(string2))
{
  // this line WILL print
  System.out.println("Ignoring case, the two strings are the same.")
}

Submit "equalsIgnoreCase method" to Facebook Submit "equalsIgnoreCase method" to Digg Submit "equalsIgnoreCase method" to del.icio.us Submit "equalsIgnoreCase method" to StumbleUpon Submit "equalsIgnoreCase method" to Google

Categories
Compare

Comments