Export (0) Print
Expand All
Expand Minimize
15 out of 24 rated this helpful - Rate this topic

java.lang.String.equalsIgnoreCase(String str)

Visual Studio 2005

Determines whether two String objects contain the same data, ignoring the case of the letters in the String.

public boolean equalsIgnoreCase(String str)


Parameter Description


A java.lang.String object to compare against the current String for equality.

true if the two String objects contain either exactly the same data or if they differ only in case; false otherwise.

// string_equalsignorecase.jsl

public class Program
    public static void main(String[] args)
        String physicist1 = "Albert Einstein";
        String physicist2 = "Max Planck";
        String physicist3 = "albert einstein";

        // Are any of the above Strings equal to one another?
        boolean equals1 = physicist1.equalsIgnoreCase(physicist2);
        boolean equals2 = physicist1.equalsIgnoreCase(physicist3);

        // Display the results of the equality checks.
        System.out.println("\"" + physicist1 + "\" equals \"" +
            physicist2 + "\"? " + equals1);
        System.out.println("\"" + physicist1 + "\" equals \"" +
            physicist3 + "\"? " + equals2);

"Albert Einstein" equals "Max Planck"? false
"Albert Einstein" equals "albert einstein"? true
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.