我想從提供的數組(二維數組)減去值。我想通過使用泛型來做。任何人都可以幫助我的代碼有什麼問題。我的意思是我需要延續一些課程嗎?我得到的錯誤(運算符 - 是不明確的參數類型(S)T,T)Java減去通用值運算符減去未定義
在此先感謝。
//this method Subtracts Value from the given Matrix for all the rows but for given columns
private <T> void subtractValueFromColumns(T[][] matrix,
ArrayList<Integer> columnsIndex, T value) {
for(int i = 0; i < matrix.length; i++){
for(int j = 0; j < columnsIndex.size(); j++){
matrix[i][j] = matrix[i][j] - value;
}
}
}
所以會發生什麼,如果我叫:'subtractValueFromColumns(新的String [] [] {{「一」,「 b「,」c「},{」d「,」e「,」f「}},new ArrayList(),」z「)'? –
immibis
2014-11-05 10:04:51