To check if an array contains a number in Java, do this:
Arrays.stream(array).anyMatch(item -> item == number)
.Here's how you do it:
int[] array = new int[] { 4, 20, 33, 100 };
// false
System.out.println(
java.util.Arrays.stream(array).anyMatch(item -> item == 21));
// true
System.out.println(
java.util.Arrays.stream(array).anyMatch(item -> item == 20));