It's because the System.out.println() invocations go to the standard output stream (System.out) and the stack trace goes to the standard error stream (System.err). Two different buffered streams, which may or may not get flushed in the same order you invoke them. A simple way to make sure the output is always ordered the way you expect, in a single-threaded application, is to assign the same output stream to both System.out and System.err, using the System.setOut() and System.setErr() methods.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.