Hi. My program in end stopped working. She showed me the error.
My program:
public class Authors2 { int authors03; String authors; private Scanner scan; private Scanner scan2; private Scanner scan3; String [] books2; public void Authors(){ scan = new Scanner(System.in); System.out.println("Please write the author: "); authors = scan.nextLine(); } //scan.close(); public void Authorsandbooks(){ scan2 = new Scanner(System.in); System.out.println("Please write how much author books you want to write: " + authors); authors03 = scan2.nextInt(); scan2.nextLine(); } //scan2.close(); public void Books(){ scan3 = new Scanner(System.in); for(int i = 0; i < authors03; i++){ System.out.println("Please write author books: " + authors); books2[i] = scan3.nextLine(); } //scan3.close(); } public void Result(){ System.out.println("You have writed the author: " + authors); System.out.println("You have entered these author books: " + books2); } public void Kiak(){ Authors(); Authorsandbooks(); Books(); Result(); } }
Error's:
Please help![COLOR="#FF0000"]Exception in thread "main" java.lang.NullPointerException at Authorandbook.Authors2.Books(Authors2.java:35) at Authorandbook.Authors2.Kiak(Authors2.java:47) at Authorandbook.Main.main(Main.java:10)[/COLOR]