import java.time.Period;
public class ConstrustorExercise{
public static void main(String[] args){
Person p1 = new Person("smith",80);
Person p2 = new Person();
System.out.println(p1.age);
System.out.println(p2.age);
}
}
class Person{
String name;
int age;
public Person(String pName,int pAge){
name = pName;
age = pAge;
}
Person(){
age = 18;
}
}
chapter07\ConstrustorExercise.java
最新推荐文章于 2024-09-10 10:21:38 发布