E, T and V in Generics Syntax

C

Chanchal

Hi All,
a silly doubt, in the javadocs of Java 1.5 , when talking about
generics they have given E, T and V inside <>'s, like "List<E>" and
"<T> T[] toArray(T[] a) ".

What is the difference between them ie E, T and V ?


Thanks

Chanchal
 
F

Fred

There is no syntactical difference. The different letters are used as
hints to the types they represent. In the examples you mention:
* E - stands for "Element"
* T - stands for "Type"
* V - stands for "Value" (I'm guessing you saw this in a Map<K,V>,
where K stands for "Key")

It's a naming convention, is all it is.

Check out the Generics Tutorial if you're interested in reading more
about this:
java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
 
O

Oliver Wong

Chanchal said:
Hi All,
a silly doubt, in the javadocs of Java 1.5 , when talking about
generics they have given E, T and V inside <>'s, like "List<E>" and
"<T> T[] toArray(T[] a) ".

What is the difference between them ie E, T and V ?

They're just names. It's like how you can name a class almost anything
you want, and name variables almost anything you want. By convention generic
type names are one character long and in upper case.

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top