title: How return a multidimensional arrayList in java?
body: <p>I want to create a multidimensional array and pass it as a parameter in a method and then fill the arrayList with elements and return the new version of the arrayList to be able to use that array in different classes but I get java.lang.NoSuchMethodError: I think the problem is about the way i return the array. I searched but I could not find . How can I do it correctly?</p>
  
  <p>here is my code; </p>
  
  <pre><code>public test{
  
   public static List&lt;List&lt;String&gt;&gt; 2Darray=new ArrayList&lt;List&lt;String&gt;&gt;(); // TE ERROR IN THIS LINE
  
  
   public List&lt;List&lt;String&gt;&gt; fillArray(List&lt;List&lt;String&gt;&gt; array){
  
  BufferedReader in = null;
              ArrayList&lt;String&gt; row = new ArrayList&lt;String&gt;();
              try {
                  in = new BufferedReader(new FileReader("sampleFile.txt"));
                  String read = null;
                      while ((read = in.readLine()) != null) {
                          String[] splited = read.split("\\s+");                       
                          for(int i=0; i&lt;splited.length ; i++){                           
                              row.add(splited[i]);
                          }                        
                          array.add(row);
                      }                         
  
                  } catch (IOException e) {
                  System.out.println("There was a problem: " + e);
                  e.printStackTrace();
              } finally {
                  try {
                      in.close();
                  } catch (IOException e) {
                  }
        return array;
  }
  </code></pre>