What is the difference between <T> and <T extends Object> in java? [duplicate]

穿精又带淫゛_ 提交于 2020-08-24 06:38:18

问题


In Java generics, What is the advantage of using class GenericStack<T extends Object> {} over class GenericStack<T>{}.

I have implemented a generic stack using both of the above approaches but unable to trace out the difference. Help me to understand this.


回答1:


There's no difference. <T> and <T extends Object> are equivalent.



来源:https://stackoverflow.com/questions/30206340/what-is-the-difference-between-t-and-t-extends-object-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!