private static void countEmployees(IMap<String, Employee> employees) { // select all employees Supplier<String, Employee, Object> supplier = Supplier.all(); // choose the aggregation to perform Aggregation<String, Object, Long> aggregation = Aggregations.count(); // execute the aggregation and print the result long countEmployee = employees.aggregate(supplier, aggregation); System.out.println("Number of employees: " + countEmployee); System.out.println("\n"); // in Java 8: //long countEmployees = employees.aggregate(Supplier.all(), Aggregations.count()); }