Java generic data types

Javasoft has introduced generics data types as part of 1.5. This is one of the major items as part of this release.

Generic types or parameterized types

Writing classes,interfaces and methods in a type safe manner is called generic types. A generic class (or) a generic interface (or) a generic method can handle any type of data. Generic types are not act upon primitive data types.

When we compile the above program, compiler generates a new generic version program by substituting Integer in place of T. We can use any data type in place of "T" i.e.; we can store a float value or a string value etc as below