It's hard to step back this far in a forum like this, much easier in person. But here we go ... start to make a little class like this:
"public class MyFilter" means you're writing a new class with that name. The simplest way to write a new class is to put it in a file with the same name, ie "MyFilter.java".
"implements FilenameFilter" means you're implementing an interface. You are required to write all the methods defined in the interface (or do some other more advanced stuff I'd like to ignore). The interface only has the one method "accept".
Back to the code you had before and fix it up to call this thing:
Now every time File.list() finds a file in the directory it will call your filter to ask if the file should go into the results. So far we coded the filter to always return true, so all files will go in just as if you had no filter. Let's make the filter more interesting:
Now it returns true for
java files, false for all others.
Is this making sense? Are you in a class or working with someone to get started in Java? If not, maybe some of the gang can recommend good First Books.