我想知道是否有人可以让我知道如何从我在主(小程序)类中创建的对象访问我的主(小程序)类中的对象。消息来源可能会澄清一些事情。通常我会使用访问器,但这是为了简单起见
public class Bravo {
int copyint;
Bravo() {
// Here I want to access the targetobj's theint from here
copyint = targetobj.theint; // I belive this doesn't work
}
}
public class Charlie {
static int theint;
Charlie() {
theint = 7;
}
}
public class alpha extends JApplet {
public void init() {
createApp();
}
public void createApp() {
Charlie targetobj = new Charlie();
Bravo askingobj = new Bravo();
}
}
TYIA-罗兰