public class Person {
private int age;
private String name;
public Person(String name,int age)
{
this.name=name;
this.age=age;
}
public void setName(String name)
{
this.name=name;
}
public void setAge(int age)
{
this.age=age;
}
public int getAge() {
return this.age;
}
public String getName() {
return this.name;
}
public void display(){
System.out.println("姓名:" + this.name + "\n年龄:" + this.age );
}
public static void main(String[] args)
{
Person person=new Person("小张",20);
person.display();
}
}
版权声明:本文为qq_63507404原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。