[wp_ad_camp_1]
Generics
is one of the best things that happened to Java
. Anyone who has worked with Java during its pre-JDK5
era can attest to that. For new developments, it has drastically reduced the amount of written codes and provided compile-time type checking using Generic Types. However, there are some things you cannot do with
Generics Types.
Contents
Call their Constructors
Generic Types cannot be instantiated using its constructor. For example:
[wp_ad_camp_1]
The compile-time error is as follows:
Create Arrays
We cannot create an array of a Generic Type.
[wp_ad_camp_2]
The compile-time error is as follows:
Call instanceof
Calling instanceof on Generic Types results in compile-time errors.
[wp_ad_camp_3]
The compile-time error is as follows:
Use primitives as Generic Type Parameters
Generics only deal with classes and objects.
[wp_ad_camp_4]
The compile-time error is as follows:
Create static variable
Generic Types cannot be used to create
static variables.
[wp_ad_camp_5]
The compile-time error is as follows: