package com.shrimpking.t6;
import com.sun.corba.se.impl.orb.PropertyOnlyDataCollector;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/16 12:46
*/
class Person5{
private String name;
private int age;
public Person5(){
this.name = "UnKnowName";
this.age = 0;
}
public Person5(int age){
this.name = "NoName";
this.age = age;
}
public Person5(String name,int age){
this.name = name;
this.age = age;
}
public void talk(){
System.out.printf("我是%s,今年%d岁%n",this.name,this.age);
}
}
public class ConstructOverload2
{
public static void main(String[] args)
{
//声明无参构造,修复错误
Person5 p = new Person5();
p.talk();
}
}
09-15
178
09-12
212