I am creating a Register Employee Menu.
If there is a space on the String variables, then the scanner passes one line ahead, for no reason.
Output and input results
Code
System.out.println("===========MENU REGISTER EMPLOYEE=============\n");
System.out.println("Enter data that is being asked\n");
System.out.println("Employee ID:\n");
readerEmployeeID = sc.nextInt();
System.out.println("Role ID:\n");
readerRoleID = sc.nextInt();
System.out.println("Name:\n");
readerName = sc.next();
System.out.println("Address:\n");
readerAddress = sc.next();
System.out.println("PhoneNumber:\n");
readerPhoneNumber = sc.nextInt();
System.out.println("Email:\n");
readerEmail = sc.next();
System.out.println("SOC:\n");
readerSoc = sc.nextInt();
Attempts to solve
I already tried:
nextLine()
next()
next().trim()
nextLine().trim()
But it still passes one line ahead.
Why is this happening?