Java generic method declaration fundamentals

前端 未结 3 791
慢半拍i
慢半拍i 2021-01-14 09:36

I\'m starting to learn Genericsfor Java and I read several tutorials, but I\'m a bit confused and not sure how a generic method is declared.

<
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-14 10:22

    If you have a requirement in your method where you need to return type is depends on your method parameter at that time you can write angle bracket before method signature as shown in your example, In short, as word suggest Generic is used for feature where same class or utility required to be used for multiple type of objects

提交回复
热议问题