Arrays.contains code example
Example 1: js array contains
let fruits = ["Banana", "Orange", "Apple", "Mango"];
let do_contain = fruits.includes("Mango"); // contain: true
Example 2: java check if element exists in array
// Convert to stream and test it
boolean result = Arrays.stream(alphabet).anyMatch("A"::equals);
if (result) {
System.out.println("Hello A");
}
Copy
Example 3: arrays .contains methof
private static final Set<String> VALUES = Set.of(
"AB","BC","CD","AE"
);