Re: [問題] generic type parameter bound?

看板java作者 (邀怪)時間16年前 (2009/05/01 15:37), 編輯推噓2(202)
留言4則, 2人參與, 最新討論串3/8 (看更多)
※ 引述《Senkousha ( )》之銘言: : 可是後面的註解黃字部份讓我覺得很奇怪: : Returns the live ordered list of type bounds of this type parameter. : For the type parameter to be plausible, there can be at most one class : in the list, and it must be first, and the remaining ones must be : interfaces; the list should not contain primitive types : (but array types and parameterized types are allowed). : type bound 可以放 array type 嗎? :Q : 在什麼情況下可以放呢? Java type parameter bounds 應該是不能有 array。 我猜這純粹是 Eclipse JDT documentation 上的錯誤... 你如果把 array 當成 bounds,應該連那個 TypeParameter 的 AST Node 都不會建出來吧? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.165.161.253

05/02 01:19, , 1F
請比較 List<String[]> 跟 List<String>[]. 何者不合法?
05/02 01:19, 1F

05/02 01:23, , 2F
你寫的這兩個都沒有 type bounds...
05/02 01:23, 2F

05/02 01:25, , 3F
type bound 是像 <T extends A,B> 中的 A 和 B, 不是 T
05/02 01:25, 3F

05/02 13:37, , 4F
List<? extends Object[]> z = new ArrayList<String[]>();
05/02 13:37, 4F
文章代碼(AID): #19-nStGV (java)
討論串 (同標題文章)
文章代碼(AID): #19-nStGV (java)