How to match Upper Cased Characters with Lower Cased Characters without using ToUpper/ToLower, is that possible?
Example:
String content = "are";
String keyword = "ARE";
if(content==keyword ){
System.out.println("Working!");
}else{
System.out.println("Not Working!");
}
The code above will print Not Working!.
Example 2:
String content = "how are you?";
String keyword = "ARE";
if(content.matches("(.*)(\\b)"+keyword+"(\\b)(.*)"))){
System.out.println("Working!");
}else{
System.out.println("Not Working!");
}
Rule 1: Use
string1.equals(string2)instead ofstring1 == string2to compare strings.You’ll find
.equalsIgnoreCase(...)for your purpose.