class Person
{
/**姓名*/
private String name;
/**年龄*/
private int age;
/**国家*/
private static String country;
public Person()
{
}
public Person(String name,int age)
{
this.name=name;
this.age=age;
}
public Person(String name,int age,String country)
{
this.name=name;
this.age=age;
this.country=country;
}
/**
获取国籍
*/
public String getCountry() {
return country;
}
/**
设置国籍
*/
public void setCountry(String country)
{
this.country = country;
}
/**
获取姓名
*/
public String getName() {
return name;
}
/**
设置姓名
*/
public void setName(String name) {
this.name = name;
}
/**
获取年龄
*/
public int getAge() {
return age;
}
/**
设置年龄
*/
public void setAge(int age) {
this.age = age;
}
/**show方法主要用以输出名字,年龄,国籍*/
public void show()
{
System.out.println(name+"~~~"+age+"~~~"+country);
}
}
public class PersonTest
{
public static void main(String[] args)
{
Person p=new Person("小哲",23,"中国");
p.show();
Person p2=new Person("小情",24,"美国");
p2.show();
Person p3=new Person("小玥",23);
p3.show();
Person p4=new Person("小芳",23,"中国");
p4.show();
//Person p5=new Person("小含",23,"美国");
//p5.show();
}
}
|