0

{ books obj = new books();

        int n;
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter the number of books details you want to enter");

// inputting n = sc.nextInt();

        books  array[]  = new books[n];


            for (int i = 0; i<=n; i++) 
            {
             array[i].input();
            }

}
  • Does this answer your question? [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – xerx593 Jan 01 '22 at 13:44
  • Hi & Welcome! In your case `array[i]` "looks quite null", please try `array[i] = new book(/*...???*/);` – xerx593 Jan 01 '22 at 13:46

0 Answers0