如何在Y方向上反转2D阵列?

时间:2017-10-26 16:21:58

标签: java multidimensional-array

{{1, 2},{2, 3}, {3, 4}};

如何反转每个子数组的索引1处的值以将数组更改为:

{{1, 4},{2, 3}, {3, 2}};

1 个答案:

答案 0 :(得分:0)

for (int i=0;i<a.length;i++) {
    b[i][0] = a[i][0];
    b[i][1] = a[a.length-i-1][1];
    System.out.println(b[i][0] + " " + b[i][1]);
}