Re: [問題] 寫method泛型時,遇到一個問題
※ 引述《NullLife (哀莫大於心死)》之銘言:
: 嗯...是可以運作了,感謝sbrhsieh大大的回覆。
: 但是我想了很久,也試了一下我的想法,還是有問題,
: public <ListType extends List<MapType>
: ,MapType extends Map<?, ?>>
: void sort2(ListType targetList) {
: // 內容...
: }
為什麼不這樣寫?
public <K, V> void sort(List<Map<K, V>> list) {
//..
}
或是
public <K extends Comparable<K>, V extends Comparable<V>>
void sort(List<Map<K, V>> list) {
//..
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.163.46.230
討論串 (同標題文章)
java 近期熱門文章
PTT數位生活區 即時熱門文章