????JAVA???????????????????????????????????????????????????????????????????
????NewObject o = new NewObject();
????NewObject o = new NewObject("test");
????NewObject o = new NewObject(new String[]{"aaa"??"bbb"});
?????????????????????java.lang.Class<T>???????JAVA??????????
????1?????????
??????????п?????????????????
public class NewObject
{
String name;
public NewObject(String[] name)
{
this.name = name[0];
System.out.println(“ the object is created!”);
}
public void write()
{
System.out.println(this.name);
}
}
??????????′??????????????
NewObject no = null;
try
{
no = (NewObject)Class.forName(className).newInstance();
no.write();
}
catch (InstantiationException e)
{
e.printStackTrace();
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}