Can someone please help me with the following code. My temp array of Point2D's never overwrite the previous one when the for loop execute again.
I used for-loops to print data in order to test if temp array does change...and it certainly don't... Why would something like this happen?
Point2D is defined in a different class. It's x, y and z values are public.
I think it may be the .clone() function?
Thanks!
Point2D[] pointArr;
pointArr = populateArr(N);
for (int i = 0; i < N; i++)
{
Point2D[] temp = pointArr.clone();
if (i >= 0)
{
Point2D exch = temp[i];
temp[i] = temp[0];
temp[0] = exch;
//temp[0].z = 0.0;
}
System.out.println();
temp = determine_slopes(temp, N);
Arrays.sort(temp, temp[0].X_ORDER);
}
EDIT 1: Just to clarify... I actually WANT the Point2D[] temp to change with each iteration... But for some reason it doesn't change. What may be the problem?
EDIT 2: My output for pointArr is as follow:
10000 0 0.0 0 10000 0.0 3000 7000 0.0 7000 3000 0.0 20000 21000 0.0 3000 4000 0.0 14000 15000 0.0 6000 7000 0.0
When I print I print the temp after the first Iteration my ouput does not look like pointArr's... It's totally different.