public class Person {
/**
* 无参构造
* */
public Person(){
System.out.println("我是无参构造");
}
/**
* 有参构造
* */
public Person(String arg){
System.out.println("我是有参构造");
}
}
主函数调用如下
public class demo {
public static void main(String[] args) {
Person p1 = new Person();
Person p2 = new Person("调用有参构造");
}
}