class NestedException {
/* 构造方法。 */
protected NestedException() {
}
/** 这个方法检测数字的格式。
* @param argument 用于存储 args 的值。
*/
public test(String[] argumnet) {
try {
int num = Integer.parseInt(args[1]);
/* 嵌套 try 块。 */
try {
int numValue = Integer.parseInt(args[0]);
System.out.println(“args[0] + “的平方是 " + numValue * numValue);
} catch (NumberFormatException nb) {
System.out.println(“不是一个数字! ");
}
} catch (ArrayIndexOutOfBoundsException ne) {
System.out.println(“请输入数字!!!");
}
}
/**main方法*/
public static void main(String[] args) {
NestedException obj = new NestedException();
obj.test(args[0]);
}
}



