title: How do I initialize a two-dimensional array?
body: <pre><code>public class example
  {
      static class point
      {
          int x;
          int y;
      }
  
      static void main(String args[])
      {
          point p = new point();
          point[] p1 = new point[5];
          point[][] p2 = new point[5][5];
  
          p.x = 5; //No problem
          p[0].x = 5; //When I run the program, it gives error:java.lang.NullPointerException
          p[0][0].x = 5; //When I run the program, it gives error:java.lang.NullPointerException
      }
  </code></pre>
  
  <p>How can I initialize p[].x and p[][].x?</p>