为什么第一种编译失败,第二种能够通过
有人说第一种里的System.out.println("A")是垃圾语句,那么第二种里的
System.out.println("A") 却不是垃圾语句,垃圾语句是怎样判断与定义的呢???
我在网上搜了 真没有,所以才来这里问问大家,版主留情不要删啊
第一种:
class Demo
{
public static void fun()
{
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 showExce()throws Exception
{
throw new Exception();
}
public static void main(String[] args)
{
try
{
showExce();
System.out.println("A");
}
catch (Exception e)
{
System.out.println("B");
}
finally
{
System.out.println("C");
}
System.out.println("D");
}
}
为什么第一种编译失败,第二种能够通过
有人说第一种里的System.out.println("A")是垃圾语句,那么第二种里的
System.out.println("A") 却不是垃圾语句,垃圾语句是怎样判断与定义的呢???
我在网上搜了 真没有,所以才来这里问问大家,版主留情不要删啊
有人说第一种里的System.out.println("A")是垃圾语句,那么第二种里的
System.out.println("A") 却不是垃圾语句,垃圾语句是怎样判断与定义的呢???
我在网上搜了 真没有,所以才来这里问问大家,版主留情不要删啊
第一种:
class Demo
{
public static void fun()
{
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 showExce()throws Exception
{
throw new Exception();
}
public static void main(String[] args)
{
try
{
showExce();
System.out.println("A");
}
catch (Exception e)
{
System.out.println("B");
}
finally
{
System.out.println("C");
}
System.out.println("D");
}
}
为什么第一种编译失败,第二种能够通过
有人说第一种里的System.out.println("A")是垃圾语句,那么第二种里的
System.out.println("A") 却不是垃圾语句,垃圾语句是怎样判断与定义的呢???
我在网上搜了 真没有,所以才来这里问问大家,版主留情不要删啊













