How to put input cursor after prompt java

烈酒焚心 提交于 2019-12-01 21:48:19

问题


I tried to emulate console dialog using java. The code is simple:

import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        String s;
        Scanner in = new Scanner(System.in);
        do {
            System.out.print(">>>");
            s = in.next();
            System.out.println(s);
        } while ( !new String("exit").equals(s));
     }
}

But when it works it puts cursor in the begining of line, not after prompt (">>>" in this case).
Is there any way to place cursor after the prompt? (Here is brief video to show what I mean https://youtu.be/6QA6849hR9A)


回答1:


It is a problem with IDE. When this code runs with cmd it works well. https://youtu.be/BpIcJbUI7MM



来源:https://stackoverflow.com/questions/31502176/how-to-put-input-cursor-after-prompt-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!