title: Java: nullPointerException creating Object
body: <p>So lets say i have this class call A which has a constructor of </p>
  
  <pre><code>       A(String someA, int someB , String[] someC)
  </code></pre>
  
  <p>and in another class i created a main 
  which has this as a class variable </p>
  
  <pre><code>    private static String[] someC = new String[4];
      private static ArrayList&lt;A&gt; thisA;
  </code></pre>
  
  <p>then i extract some information from a dat file</p>
  
  <pre><code>                someA= readFile.nextLine(); //some normal string such as  bob Billy
                  someB= readFile.nextInt();   //some integer like 5
                  unitCode[0] = readFile.next(); //some code such as HITHERE34
                  unitCode[1] = readFile.next(); // all the 4 is the same style
                  unitCode[2] = readFile.next();
                  unitCode[3] = readFile.next();
           thisA.add(new A(someA,someB,unitCode); // create object and store into array list
  </code></pre>
  
  <p>I tried running this and it gave me a nullPointerException error
  when i print the unitCode it returns me an address instead . how do i fix this ?</p>