I created a Java program to compare two strings:
String s1 = "Hello";
String s2 = "hello";
if (s1.equals(s2)) {
System.out.println("hai");
} else {
System.out.println("welcome");
}
It displays "welcome". I understand it is case sensitive. But my problem is that I want to compare two strings without case sensitivity. I.e. I expect the output to be hai
.
s1.equalsIgnoreCase(s2)
: (see javadoc) s1.equals(s2)