Source of HardHello.java


  1: import java.lang.reflect.*;
  2: import java.io.*;

  4: /**
  5:    This program prints "Hello, World" the hard way,
  6:    using reflection.
  7: */
  8: public class HardHello
  9: {
 10:    public static void main(String[] args)
 11:       throws NoSuchMethodException, IllegalAccessException,
 12:              InvocationTargetException
 13:    {
 14:       Method m = PrintStream.class.getDeclaredMethod(
 15:             "println", String.class);
 16:       m.invoke(System.out, "Hello, World!");
 17:    }
 18: }