package form; public class Student { private String id; //学号 private String name; //姓名 private String sex; //性别 private String age; //年龄 private String birthday; //出生日期 private String college; //学院 private int grade; //成绩 //将所有的成员变量都设置成为private类型,使用setter和getter对成员变量进行赋值 public Student() { } public Student(String id, String name, String sex, String age, String birthday, String college, int grade) { this.id = id; this.name = name; this.sex = sex; this.age = age; this.birthday = birthday; this.college = college; this.grade = grade; }//student集合 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 String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public String getAge() { return age; } public void setAge(String age) { this.age = age; } public String getBirthday() { return birthday; } public void setBirthday(String birthday) { this.birthday = birthday; } public String getCollege() { return college; } public void setCollege(String college) { this.college = college; } public int getGrade() { return grade; } public void setGrade(int grade) { this.grade = grade; } }
时间: 2024-02-10 09:05:29 浏览: 71
android2.3.5 CDMA/EVDO拨号APN解决方案
这段代码是一个Java类,名为Student,用于表示一个学生的信息。它有私有成员变量id、name、sex、age、birthday、college和grade,分别表示学号、姓名、性别、年龄、出生日期、学院和成绩。这些成员变量都被设置为private类型,因此只能通过公有的setter和getter方法对它们进行赋值和访问。构造函数有一个无参构造函数和一个带有七个参数的构造函数,用于创建Student对象并初始化其成员变量。
阅读全文