jeudi 13 septembre 2018

How Implementation of equalsIgnoreClass() of String class is working in java

Please help me in understanding the java implementation of equalsIgnoreCase() method of java.lang.String class.

Suppose i have two strings as below.

String a = "AbcdE";
String b = "abcde";

When I execute the below statement its printing false

System.out.println(a == b);

But when i see internal implementation of String class, the below is the definition of equalsIgnoreCase() method.

public boolean equalsIgnoreCase(String paramString)
{
    return this == paramString;
}

Its doing the same as I am doing a == b

a == b is giving me false but the same has been implemented in java.lang.String class and there its returning true. How its working. Can anyone explain?

Thank you very much.

Aucun commentaire:

Enregistrer un commentaire