我有代码,我想知道错误在哪里,请你帮帮我:throw line 上只有一个错误
public static void main(String[] args) {
try {
Scanner input = new Scanner (System.in);
System.out.println("Enter the number ");
int x1 = input.nextInt();
int i;
if (x1>=0&&x1<=100) {
i= (int) Math.pow(x1,2);
System.out.println("the squre of "+ x1 + " is "+ i);
}
else
throw new MyException(); // what is the error here?
} catch(MyException me) {
System.out.println(me);
String message = me.getMessage();
}
}
public class MyException extends Exception {
public String getMessage() {
return " the number is out of ring";
}
}
}