String Handling – equalsIgoreCase ( )

equalsIgoreCase ( )

 

            Syntax

     boolean equalsIgnoreCase (String str);

equalsIgnoreCase ( ) method of String is used to compare given string with the string of invoking object by ignoring case. If given string is matched with the string of invoking object them it will return true otherwise returns false.

class Example

{

public static void main (String arg[ ] )

{

String s = “Code project”;

boolean b = s.equalsIgnoreCase(“Code project”);

System.out.println(b);

System.out.println(s.equalsIgnoreCase(“code project”));

System.out.println(s.equalsIgnoreCase(“Solutions”));

System.out.println(s.equalsIgnoreCase(“Problem”));

System.out.println(s.equalsIgnoreCase(“Answer”));

}

}

output :-

true

true

false

false

false

Leave a Reply

Your email address will not be published. Required fields are marked *