【问题标题】:Eclipse: How can I get the cursor to appear at the latest point in the console?Eclipse:如何让光标出现在控制台的最新位置?
【发布时间】:2016-09-14 05:41:30
【问题描述】:

我正在使用 Eclipse 来运行下面的 Java 程序。当程序等待读取第二行时,为什么光标会出现在“Your first string is:”行的开头?如何将光标设置为始终显示在控制台的最新位置?

public class Test {

    public static void main(String[] args) throws IOException {
        System.out.println("Enter first string: ");

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String enteredText = br.readLine();

        System.out.println("Your first string is: " + enteredText);

        System.out.println("Enter second string: ");
        enteredText = br.readLine();

        System.out.println("Your second string is: " + enteredText);
    }
}

【问题讨论】:

    标签: java eclipse input console cursor


    【解决方案1】:

    标准的 Eclipse 控制台存在各种问题。您可以尝试使用外部控制台。这个答案https://stackoverflow.com/a/908901/4726069

    已经很好地描述了它的配置

    在这种情况下,直接在 shell 中运行程序可能更简单。你可以使用'javac'命令来编译和'java'这样运行:

    javac Test.java
    java Test
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多