Type parameter with method
Syntax for type parameter with method
<T> void putData(T t){}
<T> T makeData(T t){}
<T> T dataList(List<T> list){}
<T extends Human> T dataList(List<T> list){}
In above definition you can pass the list which contains objects which are subclass of Human. You cannot pass any other object.
<T> void putData(T t){}
<T> T makeData(T t){}
<T> T dataList(List<T> list){}
<T extends Human> T dataList(List<T> list){}
In above definition you can pass the list which contains objects which are subclass of Human. You cannot pass any other object.
void dataList(List<Human> list)
Here in this definition you cannot pass list having objects which are sub classes of Human.
Here you can pass only Human list because the inheritance concept is apply to List class not to human. But when you use Generic type Inheritance concept apply to the type parameter level.