How to check if an ArrayList contains a value in Java?

To check if an ArrayList contains a value in Java, call contains method.

Here's how you do it:

java.util.List<String> list = new java.util.ArrayList<>();

list.add("Hello");
list.add("World");

System.out.println(list.contains("Hello")); // true
System.out.println(list.contains("World")); // true
System.out.println(list.contains("Bye")); // false