package com.imooc;
import java.lang.Throwable;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
//Throwable able = new Throwable("想吐xx。。。");
//System.out.println(able.toString()); // 输出该异常的类名
//System.out.println(able.getMessage()); // 输出异常的信息
//able.printStackTrace(); // 打印栈信息
for(int i=0;i<20;i++){
try{
eat(i);//发生异常点
}catch(Nomoney e){
System.out.println(e.getMessage());
System.out.println(e.toString());
e.printStackTrace();
}
}
}
public static void eat(int i) throws Nomoney{
if (i<=10){
throw new Nomoney("没钱了。。。");
}
else System.out.println("钱够,可以买吃的");
}
}
public class Nomoney extends Exception{
Nomoney(){
}
Nomoney(String message){
super(message);
}
}