public class Student {
private String name;
private String id;
private String email;
private ArrayList<Student> s;
public Student( String n, String i, String e)
{
n = name; i= id; e = email;
}
}
public class Library {
private ArrayList<Student> s;
public void addStudent(Student a)
{
s.add(a);
}
public static void main(String[] args)
{
Student g = new Student("John Elway", "je223", "j@gmail.com");
Student f = new Student("Emily Harris", "emmy65", "e@yahoo.com");
Student t = new Student("Sam Knight", "joookok", "fgdfgd@yahoo.com");
s.addStudent(g);
s.addStudent(f);
s.addStudent(t);
}
}
私の学生オブジェクトが学生の配列リストに追加されるようですが、そのようには機能していません。配列リストが Student クラスではなくライブラリ クラスにあるために機能していませんか?