Hi. I have these exercises to do, to write the output of some coding given. I can compile it in eclipse but doesn't mean i understand. can someone please explain this code to me. thank you.

int[] arrayA = new int[3]; //this part i know, create array size 3
int[] arrayB = arrayA;//from here i don't really understand. is this like create an array and put the first array   
in it? why would you do that?
arrayB[0] = 19;//from here is to put value in each node
arrayB[1] = 2;
arrayB[2] = 35;
for(int element: arrayA)

To understand this you need to remember:

int[] arrayA = ... creates a reference variable arrayAthat holds a pointer to an array
new int[3] creates an actuial array of 3 elements
so int[] arrayA = new int[3]; creates an array and creates a pointer to it.

line 2 creates a reference variable (pointer) called arrayB, but it does NOT create a new array. It sets the pointer to refer to the existing array that was created on line 1

Okayy.. what about for(int element: arrayA) ? it "grabs" the elements in the array?

This question has already been answered. Start a new discussion instead.