Hello more experienced users,
Can someone explain to me how it is that this code prints 012? Do arrays behave differently than ints and floats in that when you declare anyType[]1=anyType[]2, the elements of anyType[]1 are assigned to match the values of anyType[]2 throughout the rest of the method?
public class test {
public static void main(String[] args){
int[]list1={1,2,3};
int []list2={1,2,3};
list2=list1;
list1[0]=0;list1[1]=1;list2[2]=2;
for(int i=0;i<list2.length;i++)
{
System.out.print(list2[i]+"");
}
}
}