Hello All I'm writing some code and keep getting a Null Pointer Exception and for some reason I'm just hitting a mental wall.
Now I do know that null pointer is when the value its trying to use is null, but I can't seem to figure out how to fix the problem. (Errored Line is *'d out.)
public static void getMenuChoice(Dog s) {
int LCV = 0;
Scanner in = null; // create a scanner object
do {
System.out.println("Welcome to the Input Menu");
System.out.println("1: Assign the name");
System.out.println("2: Assign the owner");
System.out.println("3: Assign the age");
System.out.println("4: Assign the weight");
System.out.println("5: Assign the breed");
System.out.println("6: Assign the time");
System.out.println("7: Display Dog Information");
System.out.println("8: Quit");
System.out.print("Choose a Menu Option => ");
****************int input = in.nextInt();*********************
switch (input) {
case 1:
System.out.println("Please Enter the Dogs name");
s.setDogName(in.next());
break;
case 2:
System.out.println("Please Enter the Owners name");
s.setOwnerName(in.next());
break;
case 3:
System.out.println("Please Enter the Dogs age");
s.setDogAge(in.nextDouble());
break;
case 4:
System.out.println("Please Enter the Dogs weight");
s.setWeight(in.nextDouble());
break;
case 5:
System.out.println("Please Enter the Dogs breed");
s.setDogName(in.next());
break;
case 6:
System.out.println("Please Enter the Time");
s.setTime(in.nextDouble());
break;
case 7:
System.out.println(s);
break;
case 8:
LCV = 8;
break;
}
} while (LCV != 8);
}