I want to read a full name in from the console using java.util.Scanner() and assign that value to a string.
for example;
Type "John Smith" in console. Hit return and String s = "John Smith";
I tried writing a readString method to do this but its getting loop locked. Does anyone know a soloution?.
part of my code.
System.out.println("Name: ");
String name = readString();
and my broken method.
private String readString()
{
String s ="";
while(scanner.hasNext())
s += scanner.next();
return s;
}