注册
 找回密码
 注册
江西广告网
查看: 288|回复: 0
打印 上一主题 下一主题

try

[复制链接]

该用户从未签到

1
跳转到指定楼层
发表于 2008-12-30 11:15:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?注册

x
import java.io.*; public class Mine{ public static void main(String argv[]){ Mine m=new Mine(); System.out.println(m.amethod()); } public int amethod(){ try{ FileInputStream dis =new FileInputStream("Hello.txt"); //1,抛出异常 }catch ( Exception ex) { System.out.println("No such file found"); //2.catch捕获异常,并执行 return -1; //4,return 返回 }finally{ System.out.println("Doing finally"); //3.finally一定会执行,在return之前。 } return 0; } } 运行结果: C:\java>java Mine No such file found Doing finally -1
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表