10 Things Every Java Programmer Should Know About Ruby

Easy Reflection: Create Object

public static Object create(Class c, String value)
  throws Exception
{
  Constructor ctor = c.getConstructor(
    new Class[] { String.class } );
  return ctor.newInstance(
    new Object[] { "Hello" } );
}

public static void main (String args[])
  throws Exception
{
  Greeting g =
    (Greeting) create(Greeting.class, "Hello");
  g.show();	
}