ITPub博客

首页 > IT职业 > IT图书 > java代码块 学习

java代码块 学习

IT图书 作者:summo 时间:2021-09-09 10:02:17 0 删除 编辑

class Student {            static {                System.out.println("Student 静态代码块");            }            {                System.out.println("Student 构造代码块");            }            public Student() {                System.out.println("Student 构造方法");            }        }        class Demo2_Student {            static {                System.out.println("Demo2_Student静态代码块");            }            public static void main(String[] args) {                System.out.println("我是main方法");                Student s1 = new Student();                Student s2 = new Student();            }        }

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/225/viewspace-2815480/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-07-23

  • 博文量
    0
  • 访问量
    929