What is generic?why it is used explain briefly? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is generic?why it is used explain briefly?

I can't understand generics method.i don't know why it is declared like <E>,<T>

14th Oct 2017, 8:14 AM
Saravanan.C
Saravanan.C - avatar
2 Answers
+ 12
<T> replace type of argument that you pass to the generic fuction. For example if you pass argument of type double to the fuction, T became double, if you pass string, T became string... It used that you can use same fuction with different type of arguments.
14th Oct 2017, 1:47 PM
Vukan
Vukan - avatar
+ 1
k but what is the actual purpose
14th Oct 2017, 1:48 PM
Saravanan.C
Saravanan.C - avatar