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?
CodePudding user response:
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_
.