Use want = scan.next();instead nextLine().
The reason for your problem is that, following the previous one nextInt(), you are still on the same line, and nextLine()returns the rest of the current line.
:
Scanner sc = new Scanner(System.in);
System.out.println("nextInt() = " + sc.nextInt());
System.out.println("nextLine() = " + sc.nextLine());
, , 5, Enter, :
nextInt() = 5
nextLine() =
nextLine() , .
, , 5 yeah!, Enter, :
nextInt() = 5
nextLine() = yeah!
, " yeah!" , 5. :
String nextLine(): . , . .
, 1 10 , "":
numRandom = rand.nextInt(9)+1; // this can only be in 1..9 range inclusive!
java.util.Random:
int nextInt(int n): int 0 () ()
, Java API, Random.nextInt(int) .