在下面的代码中虽然我在roar(String roar1,StringBuilder roar3)方法中更新StringBuilder roar3但是它如何影响main()方法中的roar2?同样的事情不会影响intUpdate(int x,int y)中的int x或y,也不会影响String roar1。
public class TestReference {
public void roar(String roar1, StringBuilder roar3) {
roar1.concat("!!!");
roar3.append("!!!");
}
public void intUpdate(int x, int y) {
x=1;
y=2;
}
public static void main(String[] args) {
String roar1 = "roar";
StringBuilder roar2 = new StringBuilder("roar");
new TestReference().roar(roar1, roar2);
System.out.println(roar1 + " " + roar2);
int x=-1,y=-2;
new TestReference().intUpdate(x, y);
System.out.println(x + " " + y);
}
}