首页 > 编程语言 > 详细

jvm_演示程序主动使用java类((1)使用静态变量 (2)初始化子类)

时间:2020-01-02 20:40:17      阅读:63      评论:0      收藏:0      [点我收藏+]
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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!