title: list folders and sub folders in java
body: <p>I have been trying to display a folder list in Java using this code : </p>
  
  <pre><code>class Folder {
     boolean isFile;
     String folderName;
     List&lt;Folder&gt; subFolders = new ArrayList&lt;Folder&gt;;
  }
  
  class ListF {
     public static void main(String args[]) {
        File fname = new File("C:/hello");
        Folder obj = new Folder();
        if (fname.isDirectory()) {
           File[] fileNames;
           fileNames = fname.listFiles();
           for (i = 0; i &lt; fileNames.length; i++) {
              obj.subFolders.add(fileNames[i]);
           }
           System.out.println("The list is " + obj.subFolders);
        }
     }
  }
  </code></pre>
  
  <p>But I am getting an error in my code: </p>
  
  <pre><code>ListF.java:5: '(' or '[' expected List&lt;Folder&gt; subFolders=new ArrayList&lt;Folder&gt;;
  </code></pre>
  
  <p>Can anyone point out my error? Thanks.</p>