Hi there writing a small program for borrowing and lending books, the code compiles but alot of the time when i run this code i get "java.lang.NullPointerException" and the program stops working.
in this particular instance its relating to these lines of codes:
public void displayBooks(){
for (int i=0;i<books.length;i++){
System.out.println("code: " + books[i].getCode());
System.out.println("Title: " + books[i].getTitle());
if (books[i].getStatus() == null){
System.out.println("Status: Available");
}else{
System.out.println("Return date: " + books[i].getReturnDate());
}
System.out.println("************************");
}
}
i get the following :
java.lang.NullPointerException
at Library.displayBooks(Library.java:76)
at AssignmentTwo.start(AssignmentTwo.java:28)
at Application.main(Application.java:11)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at edu.rice.cs.drjava.model.compiler.JavacCompiler.ru nCommand(JavacCompiler.java:271)
In this same code I cannot also figure out how to make i so it displays the main menu again after executing this code.
Any help would be much appreciated.
Thanks.