title: Passing parametrized ArrayList to a function in java
body: <p>I have the following function.  </p>
  
  <pre><code>func(ArrayList `&lt;String&gt;`[] name) { ........ }  
  </code></pre>
  
  <p>The function fills the ArrayList[].  (I don't want to return the <code>ArrayList[]</code>)</p>
  
  <p>However, in the caller function the <code>ArrayList[]</code> obtained has all ArrayLists as <code>null</code>.<br>
  For eg.</p>
  
  <pre><code>name = new ArrayList[num];  
  func(name);  
  System.out.println(name[0]);
  </code></pre>
  
  <p>I get <code>NullPointerException</code> at <code>line 3</code>. Is this because of <code>line 1</code>, i.e. I am not parametrizing? If yes, is there another way this can be done? Because java does not allow creating a generic array of parametrized <code>ArrayList</code>.</p>