Re: [問題] Collections.sort一個interface List
※ 引述《shedoh (仙道)》之銘言:
: 我自己是亂試過把 C 改成 => interface C<T> extends Comparable<T>{}
先看 sort() 的 definition:
public static void sort(<T extends Comparable<? super T>>)
這是什麼意思?
也就是你丟進去的型 T,它本身必須 extends (impelments) Comparable<? super T>
? super T 又是什麼?就是那個 Comparable 的 generic type 必須是 T 的 super class
T 是 C 的 super class 嗎? 不是。
就這樣了。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 147.8.127.102
※ 編輯: superlubu 來自: 147.8.127.102 (11/12 12:23)
推
11/12 12:34, , 1F
11/12 12:34, 1F
→
11/12 12:36, , 2F
11/12 12:36, 2F
推
11/12 12:38, , 3F
11/12 12:38, 3F
推
11/12 15:12, , 4F
11/12 15:12, 4F
→
11/12 15:13, , 5F
11/12 15:13, 5F
推
11/12 17:27, , 6F
11/12 17:27, 6F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):