Chinaunix首页 | 论坛 | 博客
  • 博客访问: 704376
  • 博文数量: 147
  • 博客积分: 6010
  • 博客等级: 准将
  • 技术积分: 1725
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-22 10:36
文章分类

全部博文(147)

文章存档

2011年(1)

2010年(1)

2009年(35)

2008年(110)

我的朋友

分类: Java

2008-09-09 00:02:49

异常有两类:exception和error
throw用于抛出一个异常,throws用于抛出很多异常
public class ThrowDemo{
public static void main(String args[])throws IOException{
....
}
}
pbulic class ThrowDemo{
public static void main(String args[]){
try{
  try{
   System.out.println("我要自己制造异常了.....");
   throw new IOException("FirstException");
  }catch(IOException a){
   System.out.println("捕捉到了:"+a);
   throw new NumberFormatException("SecondException");
  }
}catch(NumberFormatException e){
   System.out.println("我又捕捉到了:"+e);
}
}
}
阅读(566) | 评论(0) | 转发(0) |
0

上一篇:自增与自减

下一篇:设置标记

给主人留下些什么吧!~~