it's Trumpy again!
Here is the code:
public static void main(String[] ar){
int[] a={1,2,3};
int x=3;
foo1(a);
foo2(x);
System.out.println(a[0]);
System.out.println(x);
}
public static void foo1(int[] a){
a[0]=55;
}
public static void foo2(int x){
x=77;
}
The output:
55
3
Trumpy's question: when I call to foo2
function it doesn't change the x
variable, the change remained in the scope of the function. but when I call foo1
it changes the array itslef, am I right?