title: Creating an array inside a static method accessible from main Java
body: <p>This is my poor attempt at trying to create an array inside a static method. What this program does is list documents that have a certain extension. I want to be able to store them in an array and access that array from main. Is it possible? This is my code so far:</p>
  
  <pre><code>package recogniseKeywords;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.util.Arrays;
  
  import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
  import org.apache.poi.xwpf.usermodel.XWPFDocument;
  
  public class KeywordsRecognition {
  
      public static void listFilesForFolder(final File folder) {
  
          String[] files = {};
          int fileSize = 0;
  
          String[] extensions = {".doc", ".docm", ".xls"};
  
          for (final File fileEntry : folder.listFiles()) {
              if (fileEntry.isDirectory()) {
                  listFilesForFolder(fileEntry);
              } else {
  
                  for(int i=0; i&lt;extensions.length; i++) {
                      //Check if contains one of the extensions and isn't a temporary file(~$)
                      if (fileEntry.getName().contains(extensions[i]) &amp;&amp; !fileEntry.getName().startsWith("~$")) {
                          System.out.println(fileEntry.getName());
                          files[fileSize] = fileEntry.getName();
                          fileSize++;
                      }
                  }
              }
          }
  
      }
  
      public static void main(String[] args) throws Exception {
  
          String[] keywords = {"Performance Enhancement", "Functional Specification", "Technical Specification", "Faults", "Arval", "Vehicle", "Fines", "Insurance"};
  
  
              final File folder = new File("C:/work");
              listFilesForFolder(folder);
  
              System.out.println(Arrays.toString(files));
  
          }
      }
  }
  </code></pre>
  
  <p>I am aware that this is a static method and that int, as well as the array, is not treated as in a non-static method, however, I don't know how to proceed further.</p>