【问题标题】:Input in the same line of the message (terminal)在消息的同一行输入(终端)
【发布时间】:2013-05-12 12:45:50
【问题描述】:

是否有允许我在System.out.println() line 的同一行中读取用户输入的语法?

例子:

What is your name?:(<-- Output)    Jack (<-- Input from user in the same line)   

【问题讨论】:

    标签: java command-line terminal


    【解决方案1】:

    使用System.out.print 而不是println

    那么你的下一个输入将在同一行。

    【讨论】:

      【解决方案2】:

      这应该适合你。

      System.out.print("What is your name?");
      

      【讨论】:

        猜你喜欢
        • 2022-12-11
        • 1970-01-01
        • 2016-03-19
        • 2023-02-05
        • 2022-07-11
        • 1970-01-01
        • 1970-01-01
        • 2015-05-11
        • 2019-02-24
        相关资源
        最近更新 更多