Computer Applications

Predict the output of the following Java program snippet:


String str1 = "Information Technology"; 
String str2 = "information technology"; 
boolean p = str1.equalsIgnoreCase(str2); 
System.out.println("The result is " + p);

Java

Java String Handling

34 Likes

Answer

The result is true

Working

str1.equalsIgnoreCase(str2) will do a case insensitive comparison of str1 and str2. As both strings contain the same characters if we ignore the case so it returns true which is stored in boolean variable p.

Answered By

20 Likes


Related Questions