在 Java 中,如何从被调用的对象中设置调用对象中的变量?我想我可以设置某种结构类,但是有人可以告诉我是否有更简单的方法可以做到这一点,例如对下面的伪代码进行一些修改:
public class Example(){
int thisInt;
int thatInt;
public static void main(String[] args){
Another myAnother = new Another();
}
setThisInt(int input){thisInt=input;}
setThatInt(int input2){thatInt=input2;}
}
public class Another(){
void someFunc(){
this.Example.setThisInt(5);//I know this syntax is wrong
this.Example.setThatInt(2);//I know this syntax is wrong
}
}