
Hi,
I have to use the indexOf function on String class in Java. I am looking for indexof case insensitive java example. Share the code with me.
Thanks

Hi,
You can convert both the string into lowercase and then use indexOf method as shown below:
String s1 = str1.toLowerCase(Locale.US);
String s2 = str2.toLowerCase(Locale.US);
if(s1.indexOf(s2)!=-1){
System.out.println("String found");
}else{
System.out.println("String not found");
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.