wslss007
发贴: 35
积分: 0
|
于 2005-10-20 11:53
public class catchDemo { public static void main(String args[]){ catchDemo object=new catchDemo(); try { System.out.println("trying"); object.sampleMethod(); System.out.println("trying after call"); } catch (Exception e) { System.out.println("catching"); System.out.println(e.getMessage()); } } public void sampleMethod() throws Exception { System.out.println("starting sample Method"); throw new Exception("From sampleMethod with love"); } }
请看如上程序,为什么输出时候没有“trying after call",我的理解是先执行try 语句,然后看throw子句中定义了一个异常,然后再跳到catch 语句来捕获异常,可以如此理解吗?
|