java if a string contains a substring code example
Example 1: string contains specific word in java
str_Sample.contains("Example"));
Example 2: check if a string contains a character java
string.indexOf('a')
Example 3: string contains specific word in java
public boolean String.contains(CharSequence s);
Example 4: how to check if a string contains a character
public static boolean containsIgnoreCase(String str, char c) {
str = str.toLowerCase();
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) == Character.toLowerCase(c)) {
return true;
}
}
return false;
}