Possible Duplicate:
Java Generics
Hi,
Can anyone please explain the difference of the three and each proper usage?
Thanks, been googling but I'm still confused on how to use each.
czetsuya
I'm assuming you're talking about Generics. The 'E' and 'T' are placeholders and can be used interchangeably in class definitions. By convention 'E' is an Element and 'T' is a Type. The question mark is a placeholder for an unknown type. You often see things like this:
List<? extends MyObject> x;
This implies that 'x' is a list of objects that are subclasses of MyObject, but we don't know what they are exactly.
See: http://docs.oracle.com/javase/tutorial/java/generics/genTypes.html
E, T, K, V, or any other generic type variables are just placeholders - they don't have any intrinsic association. You can even use lowercase letters for generic type variables, but conventionally you use a single capital letter. Read the generics tutorial from Sun.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With