Getting syntax error on token "," , {expected after this token

I know there are already similar questions here but i tried the solutions but none worked,so i providing my code and java build path configurations settings ,so kindly help.i am using java 1.8

import java.io.File;
import java.util.ArrayList;
import java.util.List;




public class Pics {
    List<String> results = new ArrayList<String>();


    File[] files = new File("/path/to/the/directory").listFiles();
    //If this pathname does not denote a directory, then listFiles() returns null. 

    for (File file : files) {
        if (file.isFile()) {
            results.add(file.getName());
        }
    }
}

I am attaching the snapshot of the error,even though the curly braces are balanced but it still show error to insert “}” to complete class bodyerrors![][1]

build config


Source: syntax

Leave a Reply