int[][] array=new int[3][3];
final int N=3;
ExceptionList exceptions=null;
if(args.length!=N*N){
printError(System.out);
}
else{
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
try{
array[i][j]=Integer.valueof(args[N*i+j]).intValue();
}
catch(NuberFormatException e){
if(exceptions==null){
exceptions=new ExceptionList();
}
exceptions.add(new AssertionError((N*i+j)+"必须是一个int!"));
}
}
if(exceptions.size()!=0){
throw exceptions;
}
}
}class ExceptionList extends RuntimeException{
private Collection exceptions;
public void inputException(Throwable error){
exceptions.add(error);
}
//override
public void pri.....
}
final int N=3;
ExceptionList exceptions=null;
if(args.length!=N*N){
printError(System.out);
}
else{
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
try{
array[i][j]=Integer.valueof(args[N*i+j]).intValue();
}
catch(NuberFormatException e){
if(exceptions==null){
exceptions=new ExceptionList();
}
exceptions.add(new AssertionError((N*i+j)+"必须是一个int!"));
}
}
if(exceptions.size()!=0){
throw exceptions;
}
}
}class ExceptionList extends RuntimeException{
private Collection exceptions;
public void inputException(Throwable error){
exceptions.add(error);
}
//override
public void pri.....
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货