package com.atzhangwl.t_p01;
/**
* @Description
* @Author zhangwl to show that jvm program use class
* @Date 2020/1/2 11:11
*/
public class RunMain {
public static void main(String[] args) {
//1、
System.out.println(MyChild_1.parentStr);
//2、
// System.out.println(MyChild_1.childStr);
}
}
class MyParent_1 {
public static String parentStr = "str from parent";
static {
System.out.println("this static block is from parent");
}
}
class MyChild_1 extends MyParent_1 {
public static String childStr = "str from child";
static {
System.out.println("this static block is from child");
}
}
jvm_演示程序主动使用java类((1)使用静态变量 (2)初始化子类)
原文:https://www.cnblogs.com/sico/p/12134575.html