[2005-11-28] Semi-Colonoscopy

Can you write a valid Java program to print out "Hello" on the standard output without using a single semi-colon in the source code? When Srikanth asked me this question, my immediate and disingenious response was to hide the semi-colon using a Unicode escape sequence like this:

 public class Sriki {   public static void main( String[] args)   {     System.out.println("Hello")\u003b   } } 
However, he has a better solution:
 public class Sriki {   public static void main( String[] args) throws Exception   {     if( System.out.getClass( ).getMethod(       "println",       new Class[] { String.class}).invoke(         System.out,         new Object[] { "Hello"}) == null)     {     }   } } 
Can you come up with a better solution?

(Originally posted on Advogato.)

Other Posts from 2005