简体   繁体   中英

Eclipse: How can I get the cursor to appear at the latest point in the console?

I'm using Eclipse to run the Java program below. When the program waits for the second line to be read, why does the cursor appear at the start of the line "Your first string is: "? How can I set the cursor to always appear at the latest point in the console?

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);
    }
}

The standard eclipse console has various issues. You could try to use external console. Configuration of it has already been described well in this answer https://stackoverflow.com/a/908901/4726069

In this case it may be simpler to run you program directly in the shell. You can use 'javac' command to compile and 'java' to run like this:

javac Test.java
java Test

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM