Consider:
public static void main(String[] args) {
String s = "AbcD";
System.out.println(s.contains("ABCD"));
System.out.println(s.contains("AbcD"));
}
Output:
false
true
I need the result to be true in both cases regardless of the case. Is it possible?
You need to convert both the strings to the same case before using contains
s.toLowerCase().contains("ABCD".toLowerCase());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With