如何用split得到一个二维数组
1个回答
展开全部
public class Fw {
public static void main(String[] args) //throws Exception
{
// TODO Auto-generated method stub
String str="1;2,3;4,5,6;7,8,9,10";
String[] arry=str.split(";");
String[][] arry3=new String[4][4];
for(int i=0;i<=3;i++){
String[] arry2=arry[i].split(",");
for(int j=0;j<=i;j++){
arry3[i][j]=arry2[j];
System.out.println(arry3[i][j]);
}
System.out.println();
}
}
}
public static void main(String[] args) //throws Exception
{
// TODO Auto-generated method stub
String str="1;2,3;4,5,6;7,8,9,10";
String[] arry=str.split(";");
String[][] arry3=new String[4][4];
for(int i=0;i<=3;i++){
String[] arry2=arry[i].split(",");
for(int j=0;j<=i;j++){
arry3[i][j]=arry2[j];
System.out.println(arry3[i][j]);
}
System.out.println();
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询