title: How to add to an array in java, and then print out using for loop?
body: <p>So in the beginning, I just had this code to add to my array:</p>
  
  <pre><code>public void getMyArray()
  {
      myArray[0] = ("String1");
      myArray[1] = ("String2");
  }
  </code></pre>
  
  <p>But I kept getting a null pointer exception whenever I called it, and I wasn't sure why. So I changed my code to this:</p>
  
  <pre><code>public void getMyArray()
  {
      String [] myArray = {"String1", "String2"};
      System.out.println(myArray);
  }
  </code></pre>
  
  <p>And now I get what seems to be the address when printing:</p>
  
  <blockquote>
    <p>[Ljava.lang.String;@1ca6218 </p>
  </blockquote>