java 封装练习题! 求解答!

2024-12-20 03:33:50
推荐回答(1个)
回答1:

public class Student {
private String name;
private int age;
private String address;
private String zipCode;
private String mobile;

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;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getZipCode() {
return zipCode;
}

public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}

public String getMobile() {
return mobile;
}

public void setMobile(String mobile) {
this.mobile = mobile;
}

public String[] getPostAddress() {
String[] array = new String[2];
array[0] = this.address;
array[1] = this.zipCode;
return array;
}

}