I am having some confusion of how method references work in Java 8. I wrote the following code segment for filtering hidden files in a folder. They are producing correct result. I am not understanding -> how method signature of listFiles method is working for option 2 of this code segment.
This is what I found in Java 8 documentation
File[] listFiles()
File[] listFiles(FileFilter filter)
File[] listFiles(FilenameFilter filter)
File[] hidden = f.listFiles((p)-> p.isHidden()); //Option 1 - function signature matching (based on my understanding)
for (int i = 0; i < hidden.length; i++) {
System.out.println(hidden[i]);
}
System.out.println("================================");
File[] hidden1 = f.listFiles(File::isHidden); //Option 2 - how this method call is working
for (int i = 0; i < hidden1.length; i++) {
System.out.println(hidden1[i]);
}