Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Java: Difference between generic type parameters

I’m relatively new to programming in general. And I’ve just recently started to learn about using generics in classes and methods. However, I’m confused about the differences between the different "standard" generic parameters. On the Oracle tutorial page for generics it shows these:

E - Element (used extensively by the Java Collections Framework)
K - Key
N - Number
T - Type
V - Value
S,U,V etc. - 2nd, 3rd, 4th types

What are the differences in their uses (the one-word descriptions they give aren’t super helpful)?

Does Java interpret the code differently depending on which one is used?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The names of type parameters have the same significance as do class names, methods names, or variable names: they help human readers understand the program. Nothing more, nothing less. The compiler does not care at all if your type parameter is called T or SuPeR_CALI_fragilisticEXPIALIDOCIOUS_.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading