I understand that when we say something equals another array we are in essence pointing to the array with our new name. If we wanted to copy an array we either need to go element by element or we need to use a method/java package.
public class puzzle {
public static void main(String[] args) {
int [] x= {1,2,4,6};
double [] u= 3.0, 4.0, 5.0, 6.0,7.0};
double [] v = {2.0, 4.0, 5.0};
puzzle(u,v,x); //1
puzzle (v,u,x); //2
}
public static void puzzle(double [] first, double [] second, int [] third){
double [] temp;
temp=first;
temp[2]=42.0;
**second= first;**
second[0]= 2.34;
}
}
we want to see what the values of x, u, v are after this has been run for (u,v,x) and for (v,u,x)
in the second puzzle v is only length 3 containing 2.34, 4.0, 42.0. Why is it only three long instead of six (2.34,4.0,42.0,6.0,7.0)
does this have to do with array v being only three long and therefore is a fixed size of three and ends up cutting off the other numbers?
( i did not choose the names)