我有三个班级:
一级
public class One {
private static Two object;
public static void set_up(Two object) {
int y = object.get();
System.out.println(y);
}
public static void prn () {
System.out.println(object.get());
}
}
二班
public class Two {
private int x;
public int get() {
return x;
}
Two(int n){
x = n;
}
}
三班
public class Three {
public static void main( String[] argv ) {
One st = new One();
Two two = new Two(2);
st.set_up(two);
st.prn();
}
}
我想改变静态变量object在课堂上Two通过method set_up(Two object)。问题是类中的静态变量与方法中的参数同名。如何修改set_up(Two object)以便将给定参数中的值复制到静态对象?
哈士奇WWW
相关分类