情况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;…
测试代码 public class SingleTest { public static String v = "StaticValue"; static { System.out.println("static静态变量:" + v); System.out.println("static静态块"); } { System.out.println("构造块"); } public SingleTest() { System.o…
<Java编程思想>学习笔记(二)--类加载及执行顺序 (这是很久之前写的,保存在印象笔记上,今天写在博客上.) 今天看Java编程思想,看到这样一道代码 //: OrderOfInitialization.java // Demonstrates initialization order. // When the constructor is called, to create a // Tag object, you'll see a message: class Tag { Tag(in…