- class Test
- {
- public static String output="";
- public static void foo(int i)
- {
- try
- {
- if(i==1)
- throw new Exception();
- output+="1"; //throw单独存在下面有语句编译不能通过不是吗?这句话不算语句?编译可以通过?
- }
- catch(Exception e)
- {
- output+="2";
- return;
- }
- finally
- {
- output+="3";
- }
- output+="4";
- }
- public static void main(String args[])
- {
- foo(0);
- System.out.println(output);//134
- foo(1);
- System.out.println(output); //13423
复制代码 |