In the code below:
public File[] findFiles (String path)
{
FilenameFilter textFilter = new FilenameFilter()
{
@override
public boolean accept(File dir, String name)
{
if(name.toLowerCase().endsWith(".txt"))
return true;
else
return false;
}
};
File[] txtFiles = new File(path).listFiles(textFilter);
return txtFiles;
}
I understand that an anonymous class, which implements the interface FilenameFilter
, is defined and instantiated. But I don't understand how the method accept
is called without being called directly.