public class SomeClass {
public static void f(int x, int [] y, int[] z){
x=2;
y[0]=x;
z= new int[5];
z[0]=555;
}
public static void main(String[] args){
int x= 111;
int[] y={222,333,444,555};
int[] z={666,777,888,999};
f(x,y,z);
System.out.println(x);
System.out.println(y[0]);
System.out.println(z[0]);
}
}
The output of this code is 111-2-666, what does f(x,y,z); exactly do? and why after execution it prints x as 111, while y[0] gets the value of the other x and prints 2 and z remains the same although it says that z[0] is 555? Everything remains unchanged except y[0] and i don't understand why.