各位帮忙看看,哪里写错了?
import java.lang.reflect.*;
class Num
{
private int x;
public int y;
Num(int x,int y)
{
this.x = x;
this.y = y;
}
}
class FieldTest
{
public static void main(String[] args) throws Exception
{
Class cnum = Num.class;
Constructor cons = cnum.getConstructor(int.class,int.class);
Num num = (Num)cons.newInstance(7,8);
Field fy = cnum.getField("y");
System.out.println(fy.get(num));
}
} |
|