Program/ Example -
// Count number of records greater than 2
//In Java 8 - count number of elements in IntStream
long countRecordsGreaterThan = IntStream.of(1, 2, 3, 4, 5).filter((n) -> n > 2 ).count();
System.out.println("Count number of records greater than 2 = "+countRecordsGreaterThan);
|
Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.