public class B extends C {
}
What does this mean? That C needs to extend A? What extra restriction am I putting instead of just saying B ext
You are defining a class B that inherits from class C, parameterized with type A. A must be a class or interface.
E.g.
class MyStringList extends ArrayList
means that MyString
IS AN ArrayList
that will only contain String
elements. This class could then define e.g. a concatenate()
method that returns the concatenation of all Strings
in the list.
Because of this inheritance, you will be able to assign an instance to a List
variable:
List strings = new MyStringList();
But you will not be able to assign it to List
type variables with other parameters:
List