class DemoTry
{
public static void func()
{
try
{
throw new Exception();
System.out.println("A");
}
catch (Exception e)
{
System.out.println("B");
}
}
public static void main(String[] args)
{
try
{
func();
}
catch (Exception e)
{
System.out.println("C");
}
System.out.println("D");
}
}
class Demo
{
public static void main(String[] args)
{
try
{
//throw new Exception();
showExce();
throw new Exception();
System.out.println("A");
}
catch (Exception e)
{
System.out.println("B");
}
finally
{
System.out.println("C");
}
}
public static void show Exce()throws Exception
{
throw new Exception();
}
}
结果编译能通过,但是如果把throw new Exception();放在try里面
不用show调用则编译通过不了,为什么啊?详细解释下 谢谢
|
|