gpt4 book ai didi

Java 错误 : Cannot convert from void to int[]

转载 作者:行者123 更新时间:2023-11-29 09:35:44 37 4
gpt4 key购买 nike

<分区>

我不明白为什么java在传入Arrays.sort(thisRow)时认为数组“thisRow”是空的。 “thisRow”对我来说似乎是一个 int[] 。这里有什么问题?

错误消息:“类型不匹配:无法在 Test.mySort(Test.java:57) 将 void 转换为 int[]”

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;
}

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com