Can we pass primitives as type parameter in generics?

Generics work only with objects. The type argument passed to the type parameter must be object type.you can not pass primitive types such as int, char etc.

Gen a=new Gen(10);//error, can’t use primitive type

No comments:

Post a Comment