Que tengo mal? alguien me puede explicar por favor.
public class Library {
book[] books=new book [20]
public Library (){
}
public Library(int BookID,Student Name) {
for (int i = 0; i < books.length; i++) {
books[i].BookName= "unknow";
books [i].BookCategory= "unknown";
books [i].BookID= i;
}
Borrow(BookID,Name);
}
public void Borrow (int BookID, Student st){
if (search (BookID) != null) {
System.out.println("The book is: "+search (BookID).BookName);
System.out.println("The book has a category: "+ search (BookID).BookCategory);
System.out.println("Borrowed to: "+ st.Name);
}
else {
System.out.println("This book does not exist");
}
}
public book search (int BookNumber)
{
for (book book : books) {
if (book.BookID == BookNumber) {
return book;
}
}
return null;
}
public void addBook (book nbook){
for (int i = 0; i < books.length; i++) {
if (books [i].BookName == null) {
books [i]= nbook;
break;
}
}
}
/**
* @param args the command line arguments
*/
}
El error que me sale
Exception in thread "main" java.lang.NullPointerException at library.Library.(Library.java:23)