【发布时间】:2020-03-20 10:29:41
【问题描述】:
我想要类似的东西:
this.x=4;
this.y=5;
this.materials = [this.x, this.y];
this.materials[0]=5;//this will change the x variable
这样的结果应该是我原来的x变量的值应该变成5了。
在 Java 中可以使用这样的变量数组吗?
【问题讨论】:
-
在 Java 中不可能。你想要 C++ 引用之类的东西。 Java 没有。
-
@khelwood 是的,类似于 C++ 参考,该死的......谢谢你的回答
-
为什么 x=5 而不是 4?
标签: java arrays pointers reference