求助 java.lang.NullPointerException
自定义了一个Book类,有bookname和bookid两个属性 public static void main(String[] args) { // TODO 自动生成的方法存根 Book [] books = new Book[3]; Scanner input=new Scanner(System.in); for(int i=0;i<3;i++) { System.out.println("请输入bookname:"); String name=input.nextLine(); books[i].bookName=name; System.out.println("请输入bookid:"); String id=input.nextLine(); books[i].bookId=id; } } 请输入bookname: l Exception in thread "main" java.lang.NullPointerException at imooc.java3.exception.BookSystem.main(BookSystem.java:20)