public class Test { public static void a(Integer i, B b) { i = 1; b.setNum(2); } public static void main(String[] args) { Integer i = new Integer(0); B b = new B(); a(i, b); System.out.println(i); System.out.println(b.getNum()); } } class B { private Integer num; public Integer getNum() { return num; } public void setNum(Integer num) { this.num = num; } }
结果:
0
2
为什么结果不是:1,2 呢
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于