0

i basically have a long array i want to copy to another array object. does this copy by refrence? i know java doesnt do refrences but i read somewhere it would pass by refrence.

char[][][] data=new char[numFiles][][],data1=new char[numFiles][][];
for (int i = 0; i < numFiles; i++) {
data[i]=split(files[i]); //line 1-Reads file into char array
data1[i]=bubbleSort(data[i]);//line 2
}

basically would line 2 affect data?

public static char[][] bubbleSort(char[][] x) {
int n = x.length;
for (int pass=1; pass < n; pass++) {
for (int i=0; i < n-pass; i++) {
if (x[i][0] > x[i+1][0]) {
// exchange elements
char[] temp = x[i];
x[i] = x[i+1];
x[i+1] = temp;
}
}
}
return x;
}
1
Contributor
1
Reply
2
Views
9 Years
Discussion Span
Last Post by nschessnerd
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.