title: How to resolve the null pointer exception when entering elements from user to store in an array?
body: <p>In the following program, I am trying to get values in an array from user. 
  However, I am getting NullPointerException after entering only two values.
  Can someone explain why I am getting this exception?</p>
  
  <pre><code>import java.util.*;
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  
  public class MemoriseMe{
  
      static int arr1[],count;
  
      public static void main(String[] args) throws IOException 
      {
          BufferedReader brObj = new BufferedReader(new InputStreamReader(System.in));
  
          int firstQuery =Integer.parseInt(brObj.readLine());
          System.out.println("Enter the elements : ");  
          String line = brObj.readLine(); // to read multiple integers line
          String[] strs = line.trim().split("\\s+");
  
          for(int i =0;i&lt;firstQuery;i++)
          {
              arr1[i]=Integer.parseInt(brObj.readLine());
          }
      }
  }
  </code></pre>