I do not understand why I keep getting this null pointer exception, I do not know a lot about references and pointers and such and just started learning classes and objects. Help is much appreciated! Here is the code with the issue:
public class Library {
public static MediaItem[] item = new MediaItem[100];
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int choice = 0;
int numberOfItems = 0;
System.out.println("Personal Lending Library!");
while (choice !=6) {
choice = menu(input);
switch(choice) {
case 1: addNewItem(numberOfItems, input);
break;
case 2:
break;
case 3: listItems(numberOfItems);
break;
case 4:
break;
}
}
}
public static void addNewItem(int numberOfItems, Scanner input) {
numberOfItems++;
System.out.print("Enter the title: ");
item[numberOfItems].title = input.nextLine();
System.out.print("Enter the format: ");
item[numberOfItems].format = input.nextLine();