我正在尝试制作一个简单的程序来演示对象的 ArrayLists 的使用。我希望能够输入要存储在对象中的详细信息以及搜索和打印对象。
我正在为学生做这件事我有我的学生课程,我已经开始了我的学生测试课程,但我正在寻找输入的帮助。
这是我到目前为止所拥有的:
package student;
public class Student {
private String studentName;
private String studentNo;
private String email;
private int year;
public Student() {
/**studentName = null;
*studentNo = null;
*email = null;
*year = -1;
*/
}
public Student(String nName, String nNum, String nEmail, int nYr) {
this.studentName = nName;
this.studentNo = nNum;
this.email = nEmail;
this.year = nYr;
}
public void setStudentName(String newStudentName) {
studentName = newStudentName;
}
public void setStudentNo(String newStudentNo) {
studentNo = newStudentNo;
}
public void setEmail(String newEmail) {
email = newEmail;
}
public void setYear(int newYear) {
year = newYear;
}
public String getStudentName() {
return studentName;
}
public String getStudentNo() {
return studentNo;
}
public String getEmail() {
return email;
}
public int getYear() {
return year;
}
}
}
package student;
import java.util.ArrayList;
import java.util.Scanner;
public class studentTest {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Student student1 = new Student();
Student student2 = new Student();
Student student3 = new Student();
Student student4 = new Student();
Student student5 = new Student();
}
}