Generic Type Example

In the example below, the bound interface, List_T, specifies a type 'T' for the type parameter <E> of List.

The generic class Vector<T> realizes the generic interface List<E> (via the bound interface List_T) with a type <T> (that is defined in its own generic definition):

public class vector <T> implements List <E>

The bound class Vector_Integer specifies a type 'Integer' for the type parameter <T> of Vector<T>. The SimpleVectorProgram class is associated to Vector_Integer, allowing it to use the attribute data type of the Vector class set to Integer.



You must create a bound class for a generalization or a realization. However, we could have specified a parameter value for the generic type <T> directly (without creating a bound class) as an attribute data type, parameter data type, or return data type, by simply typing the following expression in the type field of SimpleVectorProgram:

Vector<integer>