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
C
does not mean that C
is extending A
, it means it can have A
as the type parameter.
This is very similar to Comparable
and Comparator
interfaces in java.
Consider following example
public class NameSort implements Comparator {
public int compare(Employee one, Employee another){
return (int)(one.getName() - another.getName());
}
}
means that Comparator is using Employee objects for sorting them using its name.
You can also take another example
List list = new ArrayList();
This line means that List
is using String
objects as parameters