How to put input cursor after prompt java

2020-04-08 12:25发布

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条回答
beautiful°
2楼-- · 2020-04-08 12:34

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

查看更多
登录 后发表回答