开发者

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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜