What's difference between these?
public <T extends MyClass> void myMethod (ArrayList<T> list) {
}
public void myMethod (ArrayList<? extends MyClass> list) {
}
What's difference between these?
public <T extends MyClass> void myMethod (ArrayList<T> list) {
}
public void myMethod (ArrayList<? extends MyClass> list) {
}
<T extends MyClass>
MyClass, called T. T within the method implementation. For example, you can assign elements from the list to new variables of type T.<? extends MyClass>
MyClass. The exact substitute is unknown at compile-time and thus, cannot be referred, nor new variables of this very type can be introduced.MyClass. Additional down-casting may be needed for some specific sub-types of MyClass.In the first case, you can refer to T as being the type of the MyClass or sub-class.
In the second case T can be what ever you have defined outside this method (or nothing if you don't have a type called T)