public class Test1
{
public static void main(String[] args)
{
int x = 1;
f(x);
System.out.println(x);
}
static void f(int y)
{
y++;
}
}
------
public class Test2
{
public static void main(String[] args)
{
int[] x = new int[10];
x[0] = 1;
f(x);
System.out.println(x[0]);
}
static void f(int[] y)
{
y[0]++;
}
}
Test1 prints the value 1, but Test2 prints the value 2. Explain this in terms of Java's parameter passing mechanism and its int and array types.