情况1:try块中没有抛出异常try和finally块中都有return语句 public static int NoException(){ int i=10; try{ System.out.println("i in try block is"+i); return --i; }catch(Exception e){ --i; System.out.println("i in catch - form try block is"+i); return --i;…
package class_test; /** * 静态函数.父类.子类执行顺序 * @author root * */ public class Test { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("7"); A b = new B(); } } class A{ public static int i=generate(); pub…
在java中,其应该是先于所有的方法执行. 下面是测试代码: public class Test1 { static{ System.out.println("执行静态初始化块test1..."); } { System.out.println("执行初始化块test1"); } public Test1(){ System.out.println("执行test1构造函数"); } } public class Test2 extends Te…