Encountered in <A>,<B>,<K,V> and so on, is used in Java generics.
General use of <T> to declare type holder names, when customizing generic classes, class holder names can use T (type)
If the element of the container can use E (element), if the key value match can use K (key) and V (Value), etc.
If <?>, then the default is to allow object and its sub-classes, which are all objects in Java.
So say, if it is the word every a,b,c,d ... The definition is generics, where T is just the meaning of the name. T---type,e----Element
K----key, V----value
What if it is? Defined is the normal object or its subclasses.
To illustrate:
Set<t> represents an instance of the T class in the collection.
List<e> represents an instance of class E in the collection.
List<?> indicates that the object type in the collection is indeterminate, unspecified
The List is the same as list<?>.
the role of generics:
1, with the generic type:
List<t> list=new arraylist<t> ();
T t=list.get (0);
2. No generics:
List list=new ArrayList ();
T t= (t) list.get (0);
Believe you have seen:
A, generics only determine the type of elements within the collection, but it is at compile time to determine the type of the element and then removed when the strong turn is no longer required,
Enhanced program readability, stability and efficiency
b, without generics, if the set operation is mounted, then the element is treated as object, losing its own type, and when it is removed from the collection,
Often need to be transformed, inefficient and prone to mistakes
Java Foundation----Java e,t,? The difference