正量我想知道怎麼樣,如果可能的話,創建相同大小的數組的施氮量。幫助將不勝感激。例如:我想用相同數量的元素創建10個數組,而無需逐個創建它們:int[] a = new int[]
。希望現在更清楚。創建陣列
我的一個在評論的一個問題是+ - 「我怎麼排序的行/列矩陣行列」。我明白了 - 也許有人會覺得它有用。
int[] sortarr = new int[5]; //create array to transfer data from row to new array
for (int i=0; i<N; i++){
for (int j=0; j<5; j++){
sortarr[j] = hands[i][j]; //transfer the data from 2D array's row to sortarr
}
Arrays.sort(sortarr); //sort the row's data
for (int x=0; x<5; x++){
hands[i][x] = sortarr[x]; //transfer the data back to 2D array
}
}
也許這很明顯,但我希望這會幫助那裏的人。
你能澄清你的問題嗎?我不明白你想要做什麼。 – templatetypedef 2011-02-23 21:28:37
你能提供更多信息嗎?你需要可變數量的數組嗎? – 2011-02-23 21:29:08