对抛出异常这一块比较模糊。
public void divide(int one,int two) throws Exception{
if(two==0)
throw new Exception("两数相除,除数不能为0.");
else
System.out.println("两数相除结果为:"+one/two);
}
public void computer(){
try{
divide(5,0);
}catch(Exception e){
System.out.println(e.getMessage());
}finally{
System.out.println("Happy New Year!");
}
}
public static void main(String[] args){
BlueException be=new BlueException();
be.computer();
}
这一段catch(Exception e){
System.out.println(e.getMessage());
}没有运行,怎么回事呢?