Reputation: 1497
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);
}
}
Upvotes: 1
Views: 3729
Reputation: 418
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
Upvotes: 1