check if list contains string java code example
Example 1: check if a list contains a string java
String search = "A";
for(String str: myList) {
if(str.trim().contains(search))
return true;
}
return false;
Example 2: java arraylist contains string
boolean ans = arr.contains("geeks");