Java solution with a queue used
public class Solution {\n        public List<List<Integer>> levelOrder(TreeNode root) {\n            Queue<TreeNode> queue = new LinkedList<TreeNode>();\n      
    public class Solution {\n        public List<List<Integer>> levelOrder(TreeNode root) {\n            Queue<TreeNode> queue = new LinkedList<TreeNode>();\n            List<List<Integer>> wrapList = new LinkedList<List<Integer>>();\n            \n            if(root == null) return wrapList;\n            \n            queue.offer(root);\n            while(!queue.isEmpty()){\n                int levelNum = queue.size();\n                List<Integer> subList = new LinkedList<Integer>();\n                for(int i=0; i<levelNum; i++) {\n                    if(queue.peek().left != null) queue.offer(queue.peek().left);\n                    if(queue.peek().right != null) queue.offer(queue.peek().right);\n                    subList.add(queue.poll().val);\n                }\n                wrapList.add(subList);\n            }\n            return wrapList;\n        }\n    }
['Java']