class OtherClass
{
int i = 0;
OtherClass()
{
i ++;
}
}
public class TestOther
{
public static void main(String[] args) throws Exception
{
//方法一
OtherClass o = new OtherClass();
System.out.println("o.i = " + o.i);
//方法二
Class c = Class.forName("OtherClass");
OtherClass t = (OtherClass)c.newInstance();
System.out.println("t.i = " + t.i);
}
}