For the following code:
User myUser = new User();
User[] array1 = new User[10];
User[] array2 = new User[10];
array1[5] = myUser;
array2[5] = myUser;
Is the object myUser stored twice, or is only the address of the object stored on each of the objects?
Also does this still hold if i start messing around with the variable like:
temp = myUser;
array2[4] = temp;
Also if i make a change to myUser in one array, does it make the change to the other array?
EDIT: last question how would one store it by value instead of reference?