Document

 1 package com.mon11.day11;
 2 /** 
 3 * 类说明 :
 4 * @author 作者 : chenyanlong 
 5 * @version 创建时间:2017年11月11日 
 6 */
 7 public class Student {
 8     /**
 9      * 静态代码块,在加载类的时候已经开始执行了 只执行一次
10      */
11     static {
12 
13         System.out.println("我是静态代码块!");
14     }
15     /**
16      * 构造代码块,创建对象实例时执行,发生在调用构造方法前 只执行一次
17      */
18     {
19         System.out.println("我是构造代码块!");
20     }
21     /**
22      * 构造方法,创建对象实例时执行 只执行一次
23      */
24     public Student() {
25         System.out.println("我是构造方法!");
26     }
27 
28 public static void main(String[] args) {
29     Student Student=new Student();
30 }
31 }

运行效果:

原文地址:https://www.cnblogs.com/chenyanlong/p/7819410.html