My error reads
Exception in thread "main" java.lang.NullPointerException
at Phonebook.main(Phonebook.java:41)
I also know this error occurs again at lines 45 and 49
here is my code
import java.util.Scanner; import java.io.File; import java.io.FileNotFoundException; public class Phonebook { class Entry{ public String Name, Number, Notes; } public static Entry[] ContactList = new Entry[100]; public static java.io.File PhoneBookEntries = new java.io.File("PhoneBookEntries.txt"); public static void main(String[] args) throws FileNotFoundException{ Scanner input = new Scanner(System.in); java.io.File PhoneBookEntries = new java.io.File("PhoneBookEntries.txt"); // Entry[]ContactList = new Entry [100]; java.io.PrintWriter output = new java.io.PrintWriter(PhoneBookEntries); String tempName; Character Decision; int count; int length; /// for(int i = 0; i < 100; i++ ){// System.out.println("Codes are printed as 1 to 8 characters \n use \"e\" for enter," + "\"f\" for find, \"l\" to list and \"q\" to quit."); tempName = null; count = 0; while(count < 100){ System.out.print("Command: "); tempName = input.nextLine(); Decision = tempName.charAt(0); switch(Decision){ case 'e' : System.out.print("Enter Number: "); ContactList[count].Name = input.nextLine(); System.out.print("Notes: "); ContactList[count].Notes = input.nextLine(); length = tempName.length(); tempName = tempName.substring(2, length); ContactList[count].Name = tempName; StorePhoneBook(ContactList, count); break; case 'E' : System.out.print("Enter Number: "); ContactList[count].Number = input.nextLine(); System.out.print("Notes: "); ContactList[count].Notes = input.nextLine(); length = tempName.length(); tempName = tempName.substring(2, length); ContactList[count].Name = tempName; StorePhoneBook(ContactList, count); break; case 'f' : ReadPhoneBook(PhoneBookEntries); break; case 'F' : ReadPhoneBook(PhoneBookEntries); break; case 's' : SortList(PhoneBookEntries); break; case 'S' : SortList(PhoneBookEntries); break; case 'l' : ListAllContacts(PhoneBookEntries); break; case 'L' : ListAllContacts(PhoneBookEntries); break; } count++; } } public static void ReadPhoneBook(File PhoneBoookEntries) throws FileNotFoundException{ } public static void StorePhoneBook(Entry ContactList[], int count) throws FileNotFoundException{ java.io.PrintWriter output = new java.io.PrintWriter(PhoneBookEntries); output.print(ContactList[count]); } public static void ListAllContacts(File Phonebook)throws FileNotFoundException{ } public static void SortList(File PhoneBook)throws FileNotFoundException { } }