[英]Type mismatch when sorting 2D array
該方法應該采用2行乘3列的數組m
,對其進行排序並輸出排序后的數組
import java.util.Arrays;
public class Foo {
public static void main(String[] args) {
int[][] m1 = { { 14, 11, 13, 12 },
{ 18, 15, 13, 13 },
{ 19, 16, 15, 17 } };
sortRows(m1);
}
public static int[][] sortRows(int[][] m) {
int sorted[][] = new int[2][3];
for (int i = 0; i <= 2; i++) {
sorted[i] = Arrays.sort( m[i] ); //ERROR- cannot convert from void to int
}
return sorted;
}
}
我無法想象虛空將從何而來。 那有什么意思?
這是因為Arrays.sort()
是一個void
方法,並且沒有返回值
如有疑問,請查閱文檔
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.