Map<String, Long> noOfMaleAndFemaleEmployees=
employeeList.stream().collect(Collectors.groupingBy(Employee::getGender, Collectors.counting()));
getGender is not static method in Employee class, but here it is reference with class name the code works fine.
As far as I know in method referencing, static method should be referenced with class name and non-static method should be referenced with variable name as emp::getGender
Can some help me to understand how it is behaving here?
When non-static method is referenced with class name and it is not throwing error, can some please explain.