contains List 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: list contains
List<Integer> arr = new ArrayList<Integer>(4);
boolean ans = arr.contains(2);