title: no suitable method found for addAll(List<Integer>)
body: <p>The following is my code for LeetCode binary tree level order traversal question. It gives a compile error on line 24, for no suitable method found for addAll(List), so I understand thats because addAll(Collections c) is not defined for abstract types i.e. list, but when I change the declaration of thisLevel to ArrayList, I still get the same error.</p>
  
  <p>Why and how should the following be modified to make it a valid assignment?</p>
  
  <pre><code>/**
   * Definition for a binary tree node.
   * public class TreeNode {
   *     int val;
   *     TreeNode left;
   *     TreeNode right;
   *     TreeNode(int x) { val = x; }
   * }
   */
  public class Solution {
      public List&lt;List&lt;Integer&gt;&gt; levelOrder(TreeNode root) {
          List&lt;List&lt;Integer&gt;&gt; result=new ArrayList&lt;List&lt;Integer&gt;&gt;();
          if(root==null) return result;
          LinkedList&lt;TreeNode&gt; parents=new LinkedList&lt;TreeNode&gt;();
          List&lt;TreeNode&gt; children=new LinkedList&lt;TreeNode&gt;();
          parents.add(root);
          List&lt;Integer&gt; thisLevel=new ArrayList&lt;Integer&gt;();
          while(parents.size()!=0 || children.size()!=0){
              TreeNode p=parents.remove();
              thisLevel.add(p.val);
              if(p.left!=null) children.add(p.left);
              if(p.right!=null) children.add(p.right);
              if(parents.size()==0) {
                  result.addAll(thisLevel);
                  thisLevel=new ArrayList&lt;Integer&gt;();
                  parents=children;
                  children= new LinkedList&lt;TreeNode&gt;();
              }
          }
          return result;
      }
  }
  </code></pre>
  
  <p><a href="https://leetcode.com/problems/binary-tree-level-order-traversal/" rel="nofollow">LeetCode Question URL</a></p>