Programming in Java: Topic: Generics
Programming in Java: Topic: Generics
Topic: Generics
Contents
Introduction
Benefits of Generics
Generic Classes and Interfaces
Generic Methods
Wildcard Generic Types
Restrictions on Generics
Introduction
Enables to create classes, interfaces, and methods in which
the type of data upon which they operate is specified as a
parameter.
Introduced in Java by jdk 1.5.
Example:
static <T, V extends T> boolean isIn (T x, V[] y)
Example:
interface MinMax<T extends Comparable<T>>
{ T min(); T max(); }