帮我定义一个Java学生类,属性包括学号、姓名、年龄、邮箱、家庭住址
时间: 2023-03-29 16:00:29 浏览: 183
好的,我可以回答这个问题。以下是一个Java学生类的定义:
public class Student {
private String id; // 学号
private String name; // 姓名
private int age; // 年龄
private String email; // 邮箱
private String address; // 家庭住址
// 构造函数
public Student(String id, String name, int age, String email, String address) {
this.id = id;
this.name = name;
this.age = age;
this.email = email;
this.address = address;
}
// getter和setter方法
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
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 getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
阅读全文