java exists in list 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 check if key exists in list
if (lista.contains(conta1)) {
System.out.println("Account found");
} else {
System.out.println("Account not found");
}