For the standalone program, println
prints to the standard output, which is a PrintWriter that flushes an internal buffer after printing. From the JavaDoc for PrintStream:
[...] Optionally, a PrintStream can be created so as to flush automatically; this means that the flush method is automatically invoked after a byte array is written, one of the println methods is invoked, or a newline character or byte ('\n') is written.
printf
does not do the flushing, so (unless it's done by the REPL) there's no forcing function for it to be printed before the program ends. If you want to flush it manually, you can always do (.flush System/out)
or (println)
yourself.
Edit: you can see it in the sources of the JDK: println() calls a private method called newLine() that does the flushing:
// ... snip
synchronized (this) {
ensureOpen();
textOut.newLine();
textOut.flushBuffer();
charOut.flushBuffer();
if (autoFlush)
out.flush();