声明Friend类,表示朋友的姓名、性别、电话号码关系等信息用java写
时间: 2024-05-30 10:15:46 浏览: 90
java代码-使用java解决主方法中声明类的数组的源代码
public class Friend {
private String name;
private String gender;
private String phoneNumber;
private String relationship;
public Friend(String name, String gender, String phoneNumber, String relationship) {
this.name = name;
this.gender = gender;
this.phoneNumber = phoneNumber;
this.relationship = relationship;
}
public String getName() {
return name;
}
public String getGender() {
return gender;
}
public String getPhoneNumber() {
return phoneNumber;
}
public String getRelationship() {
return relationship;
}
public void setName(String name) {
this.name = name;
}
public void setGender(String gender) {
this.gender = gender;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public void setRelationship(String relationship) {
this.relationship = relationship;
}
}
阅读全文