I have a Integer array as follows.
Integer[] nums = new Integer[]{1,2,3};
Integer inputNum = 3;
I would like to check if 3 is present here.
Was trying to use the below code, but it doesn't accept, Integer[].
IntStream.of(nums).anyMatch(num -> num == inputNum);
IntStream java.util.stream.IntStream.of(int... values)
Is there any better approach with Java 8?
num==numwill match everything in the stream.Integer[]I reckonArrays.asList(nums).contains(inputNum)is actually neater and likely more performant. This is a case of "when you have a hammer, everything looks like a nail".