because when you enter a number
int number = scan.nextInt();
you enter some number and hit enter, it only accepts number and keeps new line character in buffer
so nextLine()
will just see the terminator character and it will assume that it is blank String as input, to fix it add one scan.nextLine()
after you process int
for example:
System.out.println("Something?: ");
int number = scan.nextInt();
scan.nextLine(); // <--
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…