Q:

I don´t know how to change my program so that i can see the ten largest files

I need to program some statistics, like Count files etc.
But I have a problem with one of the tasks: 
Write code to identify the 10 largest Files. 
My Problem is that I don´t know how to get started. I have code to get the largest file. But how i can get the ten largest files ? 
Here is one class that shows the largest file.
@Override
public String getDescription() {
   return "find largest file";
}

@Override
public void printResults(List<File> files) {
    File largest = files.get(0);
    for (File f : files)
    if (f.length() > largest.length())
    largest = f;
    System.out.println("Largest file: " + largest.getName() + " (" + largest.length() + " bytes)");
}

A:

You can sort the files by file size and get the first 10 elements. Note that you will get strange results with this code if any of your files are really big:
@Override
public void printResults(List<File> files) {
    files.sort((file1,file2) -> (int)(file1.length()-file2.length())); // This will NOT work correctly if any of the files are over 2.7 GB in size.
    List<File> largest = files.subList(0, files.size() > 10 ? 10 : files.size());
    System.out.println("Largest files:");
    for(File file : largest) {
        System.out.println(file.getName() + " (" + file.length() + " bytes)");
    }
}

