常见错误
1. ArrayList, LinkedList
(1) 错:Queue<TreeNode> queue = new ArrayList<TreeNode>();
//error: incompatible types: ArrayList<TreeNode> cannot be converted to Queue<TreeNode>
对:Queue<TreeNode> queue = new LinkedList<TreeNode>();
或: ArrayList<TreeNode> queue = new ArrayList<TreeNode>();
(2)错:Stack<TreeNode> stack = new LinkedList<TreeNode>();
//error: incompatible types: LinkedList<TreeNode> cannot be converted to Stack<TreeNode>
对:Stack<TreeNode> stack = new Stack<TreeNode>();
或:LinkedList<TreeNode> stack = new LinkedList<TreeNode>();