标签:auth 首次加载 关键字 null bsp ack 基本类型 必须 ring
package cn.lz.base; /** * 初始化 * @author lzzz * */ public class J17100805 { static { System.out.println("father static{}"); } { System.out.println("father {}"); } private int id = print("father private int id"); private static int staticId = print("father private static int"); public static int print(String str) { System.out.println(str); return 1; } public static void main(String[] args) { J17100805 j1; // static代码块会被执行 System.out.println("--------我在j1之后--------"); J17100805 j2 = new J17100805(); System.out.println("--------我在j2之后--------"); J17100805 j3 = new J17100805(); System.out.println("\n--------我是分割线--------\n"); J171008051 jj1; System.out.println("--------我在jj1之后--------"); J171008051 jj2 = new J171008051(); System.out.println("--------我在jj2之后--------"); J171008051 jj3 = new J171008051(); /**
out:
father static{} father private static int --------我在j1之后-------- father {} father private int id --------我在j2之后-------- father {} father private int id --------我是分割线-------- --------我在jj1之后-------- child static{} child private static int father {} father private int id child {} child private int id --------我在jj2之后-------- father {} father private int id child {} child private int id */ } }
package cn.lz.base; /** * 初始化 * @author lzzz * */ public class J17100805 { static { System.out.println("father static{}"); } { System.out.println("father {}"); } private int id = print("father private int id"); private static int staticId = print("father private static int"); public static int print(String str) { System.out.println(str); return 1; } public static void main(String[] args) { // J17100805 j1; // static代码块会被执行 // System.out.println("--------我在j1之后--------"); // J17100805 j2 = new J17100805(); // System.out.println("--------我在j2之后--------"); // J17100805 j3 = new J17100805(); // System.out.println("\n--------我是分割线--------\n"); J171008051 jj1; System.out.println("--------我在jj1之后--------"); J171008051 jj2 = new J171008051(); System.out.println("--------我在jj2之后--------"); J171008051 jj3 = new J171008051(); /**
out:
father static{} father private static int --------我在jj1之后-------- child static{} child private static int father {} father private int id child {} child private int id --------我在jj2之后-------- father {} father private int id child {} child private int id */ } }
标签:auth 首次加载 关键字 null bsp ack 基本类型 必须 ring
原文地址:http://www.cnblogs.com/larobyo/p/7638690.html