String[][] array = {{"a","b","c"},{"d","e","f"},{"g","h","i"}};
String[][] resultArray = [10][10];
我想将第一行数组值存储到resultArray,我该如何在java中执行此操作。请帮帮我
答案 0 :(得分:1)
尝试:
String[] resultArray = array[0]; //gets the first row of array
答案 1 :(得分:1)
String[][] array = {{"a","b","c"},{"d","e","f"},{"g","h","i"}};
String[] resultArrayPtr = array[index];
如果你想复制你将要迭代或使用clone
。
答案 2 :(得分:0)
试试这个:
复制参考
String[][] array = {{"a","b","c"},{"d","e","f"},{"g","h","i"}};
String[] resultArray = array[0];
复制值
String[][] array = {{"a","b","c"},{"d","e","f"},{"g","h","i"}};
String[] resultArray = new String[array[0].length];
System.arraycopy(array[0],0, resultArray, 0, array[0].length);