ans.toArray(new int [0] [])是什么意思?为什么它不给我带来异常的异常? [重复]

我一直在写一个需要以int [] []形式返回答案的方法。我通过声明以下内容开始使用列表:

List<int[]> ans = new ArrayList();


return ans.toArray(new int[0][]);

What does this last line of code mean? If I write the line int[][] ans = new int[0][]; and then try to add values to this I get out of bound exception. Why does it not give me an exception in the first example?