-2
List<int[][]> matrices = new ArrayList<>();
我的arraylist是这样的。我想打印存储到arrayList中的二维数组中的所有元素。我怎样才能做到这一点 ?如何打印Arraylist中的二维整数阵列
我试过一些解决方案here但这些都不适合我。
List<int[][]> matrices = new ArrayList<>();
我的arraylist是这样的。我想打印存储到arrayList中的二维数组中的所有元素。我怎样才能做到这一点 ?如何打印Arraylist中的二维整数阵列
我试过一些解决方案here但这些都不适合我。
迭代列表,并使用Arrays.deepToString
打印每一个元素:
matrices.stream()
.map(Arrays::deepToString)
.forEach(System.out::println);
或者,对Java的版本不支持流:
for (int[][] matrix : matrices) {
System.out.println(Arrays.deepToString(matrix));
}
非常感谢。这是行得通的。 –
您是否尝试过的东西?在这里显示。 – AxelH
Duplicate http://stackoverflow.com/questions/32376276/print-values-of-a-2d-arraylist-matrix – Uzair