With the code below I am getting an error reading long cannot be dereferenced, how can I solve this problem?

import java.io.File;

public class TestingClass {
    public static void main( String [] args ) {
        File actual = new File(".");
        
          
        
        for( File f : actual.listFiles())
        for( File e : actual.listFiles()){
            {
if (f.length().equals(e.length())) {
    System.out.println (e.getName() + f.length());
}
        }
    }
}



}

length() method returns a long [primitive] and you are trying to dereference it by trying to invoke a method on it. Use use the == operator for comparing primitives.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.