Ah, it is good to be back. This time, i've been playing around with the Scanner class. I'm having trouble "transferring" the contents of the Scanner (whose source is the keyboard of the user), into a String variable. This needs to be done, because the user needs to input their name, and I need to be able to store that name, before the actual gameplay begins.
Here is where I've got to so far:
As usual, I'm would be really grateful for any helpful feedback! Thanks a ton. :)
//boolean input set to false. //String playerName set to null. while (input == false) { System.out.println("Enter your username!"); Scanner player = new Scanner(System.in); if (player.hasNext(Pattern.compile("// "))) { playerName = player.toString(); //to turn the contents of player into a String once a space is detected. System.out.println("Your user name is " + playerName + "."); input = true; break; } }