Your variable f is a File, and you call list(ff). Look up the doc for File list(FilenameFilter). Make the accept() method on your filter print out its arguments. See if that makes it clear how list and filter interact. And let us know if not.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi