Scanner nextLine is being skipped [duplicate]

The nextInt() ate the input number but not the EOLN:

Create your account.
What is your age?
123 <- Here's actually another '\n'

so the first call to nextLine() after create name accept that as an input.

System.out.println("Create a name.");
name = input.nextLine(); <- This just gives you "\n"

User Integer.parseInt(input.nextLine()) or add another input.nextLine() after reading the number will solve this:

int age = Integer.parseInt(input.nextLine());

or

int age = input.nextInt();
input.nextLine()

Also see here for a duplicated question.


This doesnt actually tell you why the lines are being skipped, but as you're capturing names and passwords you could use Console:

Console console = System.console();
String name = console.readLine("Create a name.");
char[] password = console.readPassword("Create a password.");
System.out.println(name + ":" + new String(password));