test if a string contains a character java code example
Example 1: check if a string contains a character java
string.indexOf('a')
Example 2: java if string contains character
if (string.contains(character)
Example 3: string check if substring exists java
String str1 = "Java";
String str2 = "va";
if(str1.contains(str2)){
// str1.contains(str2) will be true here.
System.out.println("I am true");
}