10 Things Every Java Programmer Should Know About Ruby | [ Prev | Home | Next ] |
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();
}
O'REILLY® OSCON 2005 | Copyright 2005 by Jim Weirich (All Rights Reserved) |