class BooException extends Exception{
public BooException(String str){
super(str);
}
}
class Food{
public static void eat(int num) throws BooException{
if(num > 10){
throw new BooException("eat too much");
}else{
System.out.println("just eat, don't worry");
}
}
}
public class BooExceptionDemo {
public static void main(String[] args) throws BooException{
Food.eat(9);
}
}
class BooException extends RuntimeException{
public BooException(String str){
super(str);
}
}
class Food{
public static void eat(int num){
if(num > 11){
throw new BooException("eat too much");
}else{
System.out.println("just eat, don't worry");
}
}
}
public class BooExceptionDemo {
public static void main(String[] args) {
Food.eat(15);
}
}