Java Generic Types
A generic type is a generic class or interface that is parameterized over types. It can be used to generalize the type of parameters and return value in coding without the risk to pass a wrong type to its methods. Like the following example:
/**
* Generic version of the Box class.
* @param <T> the type of the value being boxed
*/
public class Box<T> {
// T stands for "Type"
private T t;
public void set(T t) { this.t = t; }
public T get() { return t; }
}
When initiate this class or use it, it only need to replace the type parameter with desired class type.