Syntax:
A generic class is recognized by the angle brackets that it uses to define type parameters also called sometimes type variables: T1, T2 ...Tn
//generic class pattern
class GenericName <T1, T2, ... Tn?> {
//generic class body
.....
}
Type argument:
A generic class can be invoked (used) in a declaration for making new objects. You must use operator "new" to create the object. Notice in the next pattern we use Integer as a type argument but could be another type.
//using a generic type
GenericName<Integer> objectName = new GenericName<Integer>();
Note: Type argument is the actual type we use for a type parameter to invoke the generic class. It does not have to be surrounded by double quotes. It is not a string but an actual type, recognized by the syntax color of your editor and thus by the compiler
Go back to: Annotations