Integer
, String
, etc., and user-defined types) to be a parameter to methods, classes, and interfaces.
For example, classes (like HashSet
, ArrayList
, or HashMap
) use generics very well.
<>
to specify parameter types in generic class creation.
To create objects of generic class, we use following syntax:
BaseType<Type> obj = new BaseType<Type>( )In parameter type, we can not use primitives like
int
, char
, or double
.
“You yourself, as much as anybody in the entire universe, deserve your love and affection.” ― Sharon Salzberg |