java count

Solutions on MaxInterview for java count by the best coders in the world

showing results for - "java count"
Oskar
18 May 2016
1    public static void main(String[] args) 
2    { 
3  
4        // creating a list of Integers 
5        List<Integer> list = Arrays.asList(0, 2, 4, 6, 
6                                           8, 10, 12); 
7  
8        // Using count() to count the number 
9        // of elements in the stream and 
10        // storing the result in a variable. 
11        long total = list.stream().count(); 
12  
13        // Displaying the number of elements 
14        System.out.println(total); 
15    }