如何放置输入光标后提示java [英] How to put input cursor after prompt java
本文介绍了如何放置输入光标后提示java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用java模拟控制台对话框。代码很简单:
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));
}
}
但是当它工作时,它将游标置于开始行,不是在提示后(在这种情况下为>>>)。
有没有办法在提示后放置光标?
(这里是简短的视频,显示我的意思 https://youtu.be/6QA6849hR9A )
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)
推荐答案
这是IDE的问题。当这个代码用cmd运行时,它运行良好。
https://youtu.be/BpIcJbUI7MM
It is a problem with IDE. When this code runs with cmd it works well. https://youtu.be/BpIcJbUI7MM
这篇关于如何放置输入光标后提示java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文