How to check if all the elements of array is not even using stream in Java

1 Answer

0 votes
import java.util.Arrays; 

public class MyClass {
    public static void main(String args[]) {
        int arr[] = {1, 2, 4, 6, 8, 10, 12};
            
        System.out.println(Arrays.stream(arr) 
                                 .noneMatch(e->e % 2 == 0)); 
    }
}




/*
run:

false

*/

 



answered Oct 2, 2019 by avibootz

Related questions

...