package com.xiaozhi.clazz;
public class HelloClass {
public static void main(String[] args) {
Person person=new Person(21,"jingtianxiaozhi");
}
}
class Person{
private int age;
private String name;
//构造代码块优先于构造函数
{
System.out.println("构造代码块");
}
public Person(int age, String name) {
super();
this.age = age;
this.name = name;
System.out.println("age:"+age+"name:"+name);
}
}
神奇的构造代码块
最新推荐文章于 2022-04-21 14:17:05 发布