Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Generics, is <C> equal to <T>?

Tags:

If I had a Java generic class of...

public class EntityStuff<C> extends AbstractPropertyStuff<C> implements Serializable {  } 

Is this the same as...

public class EntityStuff<T> extends AbstractPropertyStuff<T> implements Serializable {  } 

does the letter hold any significance?

like image 382
david99world Avatar asked Mar 21 '12 14:03

david99world


2 Answers

No, there is no significance.

There are conventions (see Java Generics Tutorial):

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 
like image 135
hmjd Avatar answered Oct 27 '22 23:10

hmjd


It's exactly the same, letter doesn't hold any significance. In fact, the type parameter can be any valid Java identifier, so:

EntityStuff<T> EntityStuff<t> EntityStuff<TTT> EntityStuff<ttt> EntityStuff<_t23> 

are all legal.

like image 45
socha23 Avatar answered Oct 27 '22 23:10

socha23