I'm trying to understand arguments with respect to anonymous classes. The examples in books I've seen either don't have arguments or else don't explain them well. Here's the code (from Java in a Nutshell 2nd edition example 5-8 and yes I know it's old :-)...
import java.io.*;
//Print out all the *.java files in the directory.
public static void main(String[] args)
{
File f = new File(args[0]);
String[] list = f.list(new FilenameFilter() {
public boolean accept(File f, String s) {
return s.endsWith(".java");
}
});
for (int i = 0; i < list.length; i++)
System.out.println(list[i]);
}
}
My questions is how the filename f gets applied to the 'File f' argument of 'accept', and also where does the 'String s' argument come from? Why does the 'accept' method get called, is it from the FilenameFilter constructor perhaps?
Thanks!