how to find an element in an array java code example
Example 1: java find element in array
array[array.indexOf(element)]
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