可能重复:
java:如何将二维数组拆分为两个二维数组
需要的是拆分这个数组:
int[][] bitblock = {
{1,0,1,0,1,0,1,0},
{1,0,1,0,1,0,1,0},
{1,0,1,0,1,0,1,0},
{1,0,1,0,1,0,1,0},
{1,0,1,0,1,0,1,0},
{1,0,1,0,1,0,1,0},
{1,0,1,0,1,0,1,0},
{1,0,1,0,1,0,1,0}};
这是一个 8*8 的数组,我想把它分成左右数组并存储在这里:
int[][] leftblock = new int [bitblock.length][bitblock[0].length/2];
int[][] rightblock = new int [bitblock.length][bitblock[0].length/2];
我使用了 Syste.arraycopy 方法,并且能够将位块拆分为上下数组,但我很难左右拆分它:
System.arraycopy(bitblock, 0, leftblock, 0, leftblock.length);
System.arraycopy(bitblock, rightblock.length, rightblock, 0, rightblock.length)
有人可以帮忙吗?谢谢