title: What is causing null pointer exception at runtime?
body: <p>My code compiles, but I get this error at runtime:</p>
  
  <pre><code>Exception in thread "main" java.lang.ExceptionInInitializerError
      at GUI.&lt;init&gt;(GUI.java:46)
      at GUI.main(GUI.java:252)
  Caused by: java.lang.NullPointerException
      at java.util.Objects.requireNonNull(Objects.java:203)
      at java.util.Arrays$ArrayList.&lt;init&gt;(Arrays.java:3813)
      at java.util.Arrays.asList(Arrays.java:3800)
      at db.&lt;clinit&gt;(db.java:23)
      ... 2 more
  </code></pre>
  
  <p>This is the code causing the error:</p>
  
  <pre><code>public static String strLine;
  public static String[] filearray;
  public static List&lt;String&gt; list = Arrays.asList(filearray);
  
  
  public static void load() throws IOException{
  
  FileInputStream in = new FileInputStream("slist.txt");
  BufferedReader br = new BufferedReader(new InputStreamReader(in));
  
  filearray = new String[4];
  
  while ((strLine = br.readLine()) != null) {
  
  for (int j = 0; j &lt; filearray.length; j++){
  filearray[j] = br.readLine();
  
  }
  
  }
  in.close();
  </code></pre>
  
  <p>Line 46 referenced in the error:</p>
  
  <pre><code>JList stafflist = new JList(db.list.toArray());
  </code></pre>
  
  <p>I am trying to load a text file as an Array and add it to the JList stafflist, but I get a runtime error.</p>