看板
[ java ]
討論串[問題] generic type parameter bound?
共 8 篇文章
內容預覽:
真的耶, 我剛剛試了 eclipse 一下, 雖然兩種狀況建出來的 AST tree 完全不一樣,. 但是都建得出 AST tree.. Foo<? extends Object[]> 的 AST tree 是像這樣:. ParameterizedType. TYPE: SimpleType //
(還有559個字)
內容預覽:
上面的例子並不能指出 TypeVariable bounds 可以有 array type,因為 class B. 中 TypeParameter: <T extends Object[]> 的 T 是一個 bounded TypeVariable,. 而 method func 中的 A<? ex
(還有1495個字)
內容預覽:
我想是若 <T> = String[]. void foo(T x){. ???? y = x[0]; // ==> 無法判定????是什麼型別.. }. 另一個常見 的錯誤例子 :. class C<T[]> { }. 則是若合法可能發生型別錯誤,就不再多提了.... 因為用 wildcards
(還有66個字)
內容預覽:
疑,我沒注意到這個過耶,這樣看 Java parameter type bounds 的規則. 怎麼變得有點不一致?. class A<T extends Object> { } // OK. class B<T extends Object[]> { } // compile-time error
(還有47個字)