// Declare and Initialize the Collection Set<Integer> intSet = new HashSet<Integer>(); // Add Elements intSet.add(1); intSet.add(2); intSet.add(3); intSet.add(4); // Use Stream, Predicate and Filter to get the count of elements more than 1 System.out.println(intSet.stream().filter(moreThan2Pred).count()); // Prints 3