I am geting a null pointer exception when i try to run this method, the goal is to populate the booklist object array but not over 3 objects. The error occurs when i set booklist[0] = b
private Book [] booklist;
public boolean borrowBook(Book b)
{
if(booklist == null)
{
booklist[0] = b;
System.out.println(this.name+" has successfully borrowed "+b);
return true;
}
if(booklist.length < 3)
{
booklist[booklist.length] = b;
System.out.println(this.name+" has successfully borrowed "+b);
return true;
}
System.out.println(this.name+" has reached the borrowing limit! Return those books "+this.name);
return false;
booklist.booklist == nullyou cannot accessbooklist[0]