如何将无规则的一维数组string[]组合成二维数组string[][]
例如:s1={"ewe","ewefr","sdcr"}
s2={"cvfjv"}
s3={}
s4={"cevt","efvyrj"}
如何把这些一维数组转化成二维数组s[][]
s={
{"ewe","ewefr","sdcr"}
{"cvfjv"}
{}
{"cevt","efvyrj
}
不胜感激!!!!
------解决方案--------------------------------------------------------
public static void main(String[] args) {
String[] s1 = new String[]{"a","b"};
String[] s2 = new String[]{"c","d"};
String[] s3 = new String[]{"e","f"};
String[][] s = new String[3][2]; s[0] = s1;
s[1] = s2;
s[2] = s3;
}
就差不多这样。但是请注意红色的代码,3需要根据你的一位数组的个数来定。2需要根据你所有一位数组中最长的数组的长度来定。
------解决方案--------------------------------------------------------
- Java code
s1={"ewe","ewefr","sdcr"}s2={"cvfjv"}s3={}s4={"cevt","efvyrj"}s5 = {s1,s2,s3,s4}