我有这个矩阵:
A B C D E
0 0 0 1 0 -> index 0 in arrList
0 0 1 1 0 -> index 1 in arrList
0 0 1 0 0 -> index 2 in arrList
1 0 1 0 0 -> index 3 in arrList
所以在ArrayList中,arrList包含:[[0,0,0,1,0],[0,0,1,1,0],[0,0,1,0,0],[1,0,1, 0,0]
如何从JAVA中的arrList获取A,B,C,D和E列中的值以获取作为示例输出?
Example output:
A: [0,0,0,1]
B: [0,0,0,0]
C: [0,1,1,1]
D: [1,1,0,0]
E: [0,0,0,0]
请帮忙.谢谢.
最佳答案
for(int row = 0; row < 4; row++){
for(int col = 0; col < 5; col++){
System.out.print(arrList[col][row]);
}
System.out.println();
}
这将为您提供所需的输出.
P.S.:在代码中进行编辑以获得您想要的格式的输出.