Why does it happen that the stack trace printed for the following Java program is not displayed in a proper order on the console screen? It gets mi
This has to do more with the implementation of the standard output and error streams than Eclipse.
Both System.out
and System.err
are PrintStream objects which may be passed buffered streams that do not automatically flush data to their destinations. Since they are two different streams with buffering used internally, the data you write to them may be interleaved because the streams may decide to flush at different times (the buffer contents may be filled at different times).
Calling System.err.flush()
after printing the first two stack traces and then System.out.flush()
after printing to the std output stream should get consistent results.