I don’t understand why java thinks the array “thisRow” is void when it is passed into Arrays.sort(thisRow). “thisRow” appears to be an int[] to me. What is the issue here?
Error Message: “Type mismatch: cannot convert from void to int[] at Test.mySort(Test.java:57)”
private static int[][] mySort(int[][] anArray) {
for(int i = 0; i < anArray.length; i++){
int thisRow[] = getRow(anArray, i);
int[] sorted = Arrays.sort(thisRow);
}
}
//This method will get the specified row out of the array.
private static int[] getRow(int[][] anArray, int row) {
int thisRow[] = new int[anArray[row].length];
for(int j = 0; j < anArray[row].length; j++){
thisRow[j] = anArray[row][j];
}
return thisRow;
}
Arrays.sort returns
voidnotint[]type.As per javadoc
Replace
with