使用java语言建Student类,包含学生姓名、学号、性别、专业等基本信息,实现信息录入和查看功能
时间: 2023-03-15 13:11:53 浏览: 173
Java创建一个类-类名称student
可以使用以下 Java 代码来实现:public class Student {
private String name;
private int num;
private String gender;
private String major; public Student(String name, int num, String gender, String major) {
this.name = name;
this.num = num;
this.gender = gender;
this.major = major;
} public void setName(String name) {
this.name = name;
} public String getName() {
return name;
} public void setNum(int num) {
this.num = num;
} public int getNum() {
return num;
} public void setGender(String gender) {
this.gender = gender;
} public String getGender() {
return gender;
} public void setMajor(String major) {
this.major = major;
} public String getMajor() {
return major;
}
}
阅读全文