http://www.shu.edu.cn/campus/java/chp8.html
异常的教程throws用 来 标 明 一 个 成 员 函 数 可 能 抛 出 的 各 种“ 异 常”。throw语 句 用 来 明 确 地 抛 出 一 个“ 异 常”。
class ThrowsDemo {
static void procedure( ) throws IllegalAccessException //throws用在函数声明
{
System.out.println("inside procedure");
throw new IllegalAccessException("demo"); //throw 用在这函数体内
}
public static void main(String args[])
{
try {
procedure( );
} catch (IllegalAccessException e)
{
System.out.println("caught " + e);
}
}
}
异常的教程throws用 来 标 明 一 个 成 员 函 数 可 能 抛 出 的 各 种“ 异 常”。throw语 句 用 来 明 确 地 抛 出 一 个“ 异 常”。
class ThrowsDemo {
static void procedure( ) throws IllegalAccessException //throws用在函数声明
{
System.out.println("inside procedure");
throw new IllegalAccessException("demo"); //throw 用在这函数体内
}
public static void main(String args[])
{
try {
procedure( );
} catch (IllegalAccessException e)
{
System.out.println("caught " + e);
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货