java问题:检查代码
public class Alone7_1{
public static void main(String[] args){
if(args.length==2){
int cheng1=args[0],cheng2=args[1];
int a=cheng1*cheng2;
System.out.println(a);
}
else{
System.out.println("错误:需要两个整数");
}
}
}
参考答案:public class Alone7_1 {
public static void main(String[] args) {
if (args.length == 2) {
int cheng1 = Integer.parseInt(args[0]), cheng2 = Integer.parseInt(args[1]);
int a = cheng1 * cheng2;
System.out.println(a);
} else {
System.out.println("错误:需要两个整数");
}
}
}