I have a problem, I have a package event which contains a class student in this class I have this method
public void addEvents( Event e) {
if(e!=null)
events.add(e);
}
in a second package I have created an event and I want to call the above method to add the event created to a ArrayList
event.setDateEvent(new Date(day,month,year));
student.addEvents(event);
this error is displayed
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.util.ArrayList.add(Object)" because "this.events" is null
at event.Student.addEvents(Student.java:48)
at test.StudentTest.main(StudentTest.java:43)