A bit more detail: the output from your print statements is going to System.out
. However, the exception messages are going to System.err
(see this). These two are separate output streams that both happen to go to the same place: your console. They are buffered and processed independently. In the second situation you show, the print
statements are buffering up but not yet printed when the exception happens.
edit There is an added complication here, which is that the Eclipse console is not a real Windows console. As noted here among other places, there have in the past been problems with the Eclipse console on Windows platforms because Windows does not give Eclipse a good way to make its console behave just like a native console. If you add flush
calls and still have problems, try running your program from a command prompt and see if that makes a difference.