arrayList和⼆维数组的转换//⼆维数组转换为ArrayList
public static void main(String[] args) {
String[][] str = {
{ "语⽂", "100" },
{ "英语", "90" },
{ "数学", "90" },
};
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < str.length; i++) {
for (int j = 0; j < str[i].length; j++) {
list.add(str[i][j]);
}
}
Iterator it = list.iterator();
while (it.hasNext()) {
System.out.());
}
/
String [][]strArray=new String[list.size()][];
for (int i = 0; i < list.size(); i++) {
String []temp={(i)};
for (int j = 0; j < str.length; j++) {
数组转换成字符串
strArray[i]=temp;
}
}
for (int i = 0; i < list.size(); i++) {
for (int j = 0; j < strArray[i].length; j++) {
System.out.print(strArray[i][j]+"  ");
}
System.out.println();
}
}
}
/
public String[][] getArray() {
ArrayList<LeakInfo> rs = new UserInfoDM().load();
String[][] excel_str = new String[rs.size()][]; // 转换为⼆维数组
for (int i = 0; i < rs.size(); i++) {
LeakInfo user = rs.get(i);
String[] q = { Username(), Result()};//获取对象成员保存⾄⼀维数组
for (int j = 0; j < excel_str.length; j++) {
excel_str[i] = q;
}
}
return excel_str;
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。