-2
if((type.toLowerCase()).equals("phone number")) {                                   
    System.out.println("Enter phone number: ");
    kb.nextLine();
    individual.setPhoneNumber(kb.nextLine());
}

Basically if the user enters a phone number the first time, it is ignored. The user must then re-enter the information for the string and it will work the second time.

For an identical piece of code in which an integer is enterred, however, it works on the first input.

keyser
  • 17,711
  • 16
  • 54
  • 93
Test
  • 99
  • 1
  • 2
  • 7

1 Answers1

2

Did you mean to call nextLine() again as a parameter?

if((type.toLowerCase()).equals("phone number")){                                    
    System.out.println("Enter phone number: ");
    String number = kb.nextLine();
    individual.setPhoneNumber(number);
}
austin wernli
  • 1,803
  • 9
  • 15