I have the following code for FileFilter:
final FileFilter directoryFilter = new FileFilter()
@Override
public boolean accept(final File pathname)
{
return pathname.isDirectory();
}
};
I want to write this using a method reference. This was my first attempt:
final File test;
final FileFilter directoryFilter = test::isDirectory;
This gives me an error:
incompatible types: invalid method reference.
This works if I try this with a lambda expression:
final FileFilter directoryFilter = pathname -> pathname.isDirectory()
How do I change my code to get a link to a method?
Kevin source
share