I created a Java program to compare two strings:
String str = "Hello"; if (str.equals("hello")) { System.out.println("match"); } else { System.out.println("no match"); }
It's case-sensitive. How can I change it so that it's not?
You have to use the compareToIgnoreCase method of the String object.
compareToIgnoreCase
String
int compareValue = str1.compareToIgnoreCase(str2);
if (compareValue == 0) it means str1 equals str2.
if (compareValue == 0)
str1
str2
More about string can be found in String Class and String Tutorials