Tuesday, May 25, 2010

A Java printf quine

The challenge: can you write a printf statement in Java that prints the statement itself?

The answer: a resounding yes (see output on ideone.com)
System.out.printf("System.out.printf(%1$c%2$s%1$c,34,%1$c%2$s%1$c);",34,"System.out.printf(%1$c%2$s%1$c,34,%1$c%2$s%1$c);");
My, my, my. Just look at it!!! Have you ever seen such symmetrical self-generating concentrated beauty???

This is without a doubt one of my masterpieces in Java.

No comments:

Post a Comment