JAVA问题,高手请进!!

来源:百度知道 编辑:UC知道 时间:2024/06/04 09:11:35
“用main()创建一个类,令其掷出try块内的Exception类的一个对象。为Exception的构建器赋予一个字串参数。在catch从句内捕获违例,并打印出字串参数。添加一个finally从句,并打印一条消息,证明自己真正到达那里。”怎么做啊?很急的,高手们不吝赐教啊!

文件ExceptionTest.java
class Test{
Test() throws Exception{
throw new Exception("自定义异常e!");
}
}
public class ExceptionTest{
public static void main (String[] args){
try {
Test t=new Test();
}catch(Exception e){
System.out.println("catch块捕获:"+e.getMessage());
}finally {
System.out.println("进入finally块!");
}
}
}