ABSTRACT

The fundamental idea behind using Generic is to let type (Integer, String, … etc., and user-defined types) be a parameter to classes, methods, and interfaces. One of the most important features of Generics is Type Safety. Another key component of Generics is its performance. Applying value types with non-generic collection classes typically follows up with boxing and unboxing overhead once a value type is translated to reference type. While most developers will usually use the existing generic types within the base class libraries, it is certainly possible to build own generic members and custom generic types. Generic types and methods are visually distinguishing because they always have angle brackets after the name. Covariance and contravariance refer to the ability to use a more derived type (more specific) or a less derived type (less specific) than initially specified.