Storeing a users input as a string in JAVA
Firstly I am very new to JAVA, so I apoligise if I am not quick to pickup on something.
In the example below h开发者_运维问答ow could I store the user's input to a string as well as return it?
Scanner inputme = new Scanner(System.in);
System.out.println(inputme.nextLine());
I was thinking something along the lines of:
inputme.WritetoString(thestringname);
Simply use an intermediate variable:
Scanner inputme = new Scanner(System.in);
String line = inputme.nextLine();
// Do whatever in between
System.out.println(line);
Then the line
variable is a String containing... the line :)
精彩评论