public class Test{
void Check(int num) throws NumberException{
if(num>100 || num<0){
throw new NumberException();
}else{
}
}
public static void main(String arg[]){
Test test = new Test();
try {
test.Check(101);
} catch (NumberException e) {
e.printStackTrace();
}
}
}
class NumberException extends Exception{
private static final long serialVersionUID = 1L;
NumberException(){
super("請輸入0到100之間的數");
}
}