Paul Clapham wrote:Have a look at the Java API for a start. On the page for FilenameFilter (and in fact on every class and interface's page), at the top, there's a "USE" link. That will show you everything in the standard API which uses FilenameFilter. If you really feel keen, you can then look in the source code for the standard API and see how people have used that method.
Paul Clapham wrote:
Dinkar Joshi wrote:Since accept is an instance method called (indirectly, through FilenameFilter reference) by a File object, what is the use of File object calling a method and passing itself to a method?
First of all, the code inside the FilenameFilter might well need to know about the directory in question before it can say yes or no. So the most straightforward way to arrange that is to pass the directory as a parameter.
And second, I don't believe you have looked at all other places where a FilenameFilter is used in the standard API.
Paul Clapham wrote:
Junilu Lacar wrote:If you look at the example implementations on the Wikipedia article, you'll see the notify method is private, which it should be.
That's true. But the Java example there doesn't have a "Source" interface to be implemented. If it did, then it couldn't have a private "notify" method.
So yes, that "Source" interface is problematic.
Carey Brown wrote: