title: How to build array inside private fuction from null?
body: <p>Im trying to build array inside private function that gets empty array from public function , I call the private function from public and then I try to make the <code>arr[i][j] = 1</code> and then the recursion will add to <code>int j</code> +1 , but when I do the <code>arr[i][j] = 1</code> I get runtime error : NullPointerException,  I don't know the <code>arr[0].length</code> , I know only that the <code>arr.length</code> is n , any fix ?</p>
  
  <pre><code>public static int howManySorted(int n, int max) 
  {
       int i = 0;
       int j = 0;
       boolean first = false;
       int count = 0;
       int[][] arr = new int[n][];
  
  
  
       return howManySorted(n,max,arr,i,j,first,count);
  }
  private static int howManySorted(int n,int max,int[][] arr,int i,int j,boolean first,int count)
  {
      if(n &lt; 1)
          return 0;
  
      if(j &lt; n)
      {
          arr[i][j] = 1;
          count++;
          first = true;
          return howManySorted(n,max,arr,i,j+1,first,count);
      }
  </code></pre>