Class level type parameter with Extends
You can use extends in type parameter declaration When you want to restrict the types which can be used in instantiation.
For example If you create a class User, you want it to hold only Human objects.
Syntax is
public class User<X extends Human> { }
So, every time you instantiate User class the type parameter has to be subclass of Human.
class Male extends Human { }
class Female extends Human { }
you can also specify more than one type parameter in bound
class Bird{}
class Animal{}
class User{}
class Forest<X extends Bird & Animal & User>{}
Here every time you instantiate Forest class the type parameter can be subclass
of Bird or Animal or User.
You can specify at most one class at instantiate time
For example If you create a class User, you want it to hold only Human objects.
Syntax is
public class User<X extends Human> { }
So, every time you instantiate User class the type parameter has to be subclass of Human.
class Male extends Human { }
class Female extends Human { }
you can also specify more than one type parameter in bound
class Bird{}
class Animal{}
class User{}
class Forest<X extends Bird & Animal & User>{}
Here every time you instantiate Forest class the type parameter can be subclass
of Bird or Animal or User.
You can specify at most one class at instantiate time