Why does my code not work?
package demo; import java.util.List; public class Student { private String naam; private int num; private List<Student> students; public Student() { } public Student(String naam, int num) { this.naam = naam; this.num = num; } public void setStudents(Student student){ students.add((Student) students); } public List<Student> getStudents() { return students; } public static void main(String[] args) { Student student = new Student(); student.setStudents(new Student("Jen", 27)); student.setStudents(new Student("Ruurs", 28)); List<Student> stud = student.getStudents(); for (Student students: stud){ System.out.println("Name "+ students.naam + " number "+ students.num); } } }
I don't get a clear error message