Why is the output for the following code 11,21,31 11,21,31
and not 10,20,30 10,20,30
?
public class Tp {
public static void doChange(int a[])
{
for(int pos=0;pos<a.length;pos++)
{
a[pos]+=1;
}
}
public static void main(String args[])
{
int arr[]= {10,20,30};
doChange(arr);
for(int x:arr)
{
System.out.print(x+",");
}
System.out.println(arr[0]+" "+arr[1]+" "+arr[2]);
}
}