| 对程序修改了一下可以得到你想要的结果了: 
 复制代码public  class Test {
    /**
     * @param args add by zxx ,Dec 9, 2008
     */
    public static void main(String[] args) {
            // TODO Auto-generated method stub
            System.out.println(Test.test());
    }
    
    static int test()
    {
             int x=1 ;
            try
            {
                    return x;
            }
            finally
            {
                   return ++x;        //改为这句就自增了
                   // System.out.println("----"+x+"----");    
            }
    }
    
}
 |