I'm trying to figure out how to add an item to an array based on the return value of a method.
Something like where in a method you can do return array.contains(value) and automatically return a boolean, but in a way where you can, instead of returning that value, add it to an array?
Is this possible in the same format, where you don't need a conditional statement?
Sorry for the noonish question, and thanks for the help!
returnsomething, then why not just use a conditional statement? What do you mean?int[] array2 = Arrays.stream(array1).filter(n -> n > 5).toArray()