title: How to operate on an ArrayList of ArrayList in Java?
body: <p>I'm facing a problem when operating on an ArrayList of ArrayList in Java. I have this thing in my code- </p>
  
  <pre><code>ArrayList&lt;ArrayList&lt;Integer&gt;&gt; L1 = new ArrayList&lt;ArrayList&lt;Integer&gt;&gt;();
  </code></pre>
  
  <p>Problem is, I have no idea as to how I should operate on this (addition, removal, traversal etc.). I wish to create an adjacency list (for implementing simple, undirected graphs), and my instructor suggests that I should create an ArrayList of ArrayList. I know I can do the following to add new element-</p>
  
  <pre><code>L1.add(//Something I want to add);
  </code></pre>
  
  <p>But this throws up an error in the current case for obvious reasons.</p>