The code is listed below. So I expected the output to be {2 4 6 8 10}, however, when I test it, the result is {1 2 3 4 5}. I am confused now, can anyone tell me why? Thanks!
public class practice{
public void doubler(int[] a)
{
int[] b = new int[a.length];
for(int i = 0; i< a.length; i++)
{
b[i] = 2*a[i];
}
a = b;
}
public static void main(String[] args)
{
int[]c = {1,2,3,4,5};
Practice w = new Practice();
w.doubler(c);
for(int count = 0; count<c.length; count++)
{
System.out.print(c[count] + " ");
}
}
}