publicclassTestIncreace{
voidTestInc(intn)throwsException{
int[]a=newint[n];
intsum=0;
for(inti=0;i<a.length;i++){
a[i]=n%10;
n=n/10;
sum+=a[i];
}
System.out.println(sum);
}
publicstaticvoidmain(String[]args)throwsException{
try{
TestIncreacet=newTestIncreace();
System.out.println(“请输入您要测试的数据:”);
Scannerinput=newScanner(System.in);
intin=input.nextInt();
t.TestInc(in);//括号内为要测试的数据
}catch(Exceptione){
System.out.println(“非法数字”);
}
}
}