I was wondering how I could convert user input using scanner to an integer that I have already declared. I have already created the object person1 and declared the variables firstName, lastName, age and gender in the 'Person' class. I know I should be using parse but I'm unsure how to implement it within my code.
Scanner user_input = new Scanner( System.in );
System.out.println("Please input your details.");
System.out.println("First Name:");
person1.setFirstName(user_input.nextLine());
System.out.println("Last Name:");
person1.lastName = user_input.nextLine();
System.out.println("Age:");
person1.age = user_input.nextLine();
System.out.println("Gender:");
person1.gender = user_input.nextLine();
Lines 9 and 11 need modifying.