一、靜態工具方法尤爲適合泛型化安全
![](http://static.javashuo.com/static/loading.gif)
- 侷限性在於下述三個集合的類型必須徹底相同
- 利用有限制的通配符類型可使這個方法變得更加靈活
![](http://static.javashuo.com/static/loading.gif)
二、泛型方法無需明確指定類型參數的值:類型推導函數
三、等號兩邊都出現類型,顯得有些冗餘工具
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
四、泛型單例工廠對象
- 有時須要建立不可變,但又適合於許多不一樣類型的對象
- 好比,恆等函數
- 每次須要的時候都建立一個對象很浪費
- 由於他是無狀態的,泛型對象擦除以後,每一個對象都是同樣的,單例就夠了
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
五、經過包含類型參數自己的表達式,限制類型參數,稱爲遞歸類型限制blog
![](http://static.javashuo.com/static/loading.gif)
- 針對能夠與自身比較每一個類型的T : T extends Comparable<T>
![](http://static.javashuo.com/static/loading.gif)
六、總結遞歸
- 泛型方法比類型轉換更加安全和容易實現
- 泛型化現有方法,使用起來更加方便,不影響原有客戶端使用