static关键字

时间:2021-04-07 10:49:07   收藏:0   阅读:0

static关键字

public class OOPDemo01 {
        //2:赋初值
        {
            System.out.println("匿名代码块");
        }
        //1:只执行一次
        static{
            System.out.println("静态代码块");
        }
        //3
        public OOPDemo01(){
            System.out.println("构造方法");
        }

    public static void main(String[] args) {
            OOPDemo01 oopDemo01 = new OOPDemo01();
            System.out.println("==================");
            OOPDemo01 oopDemo011 =new OOPDemo01();
    }
}

输出:

静态代码块
匿名代码块
构造方法
==================
匿名代码块
构造方法
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!