62,614
社区成员
发帖
与我相关
我的任务
分享
public class Excepts {
public static void func1() throws Throwable
{
throw new Exception("from func1");
}
public static void main(String[] Str) throws Throwable
{
try
{
func1();
}
catch(Exception e)
//catch (Throwable e)
{
System.out.println("This is the main catch");
}
}
}
public class Excepts {
public static void func1() throws Throwable {
throw new Exception("from func1");
}
public static void main(String[] Str) throws Throwable {
try {
func1();
}
// catch (Exception e)
catch (Throwable e)
{
e.printStackTrace();
System.out.println("This is the main catch");
}
}
}
打印:
java.lang.Exception: from func1
at com.withiter.test2.Excepts.func1(Excepts.java:5)
at com.withiter.test2.Excepts.main(Excepts.java:10)
This is the main catch