Reputation: 5877
I am reading Java the Complete Reference 7th edition, and it says that lower bound in Java Generics are exclusive, but I found the opposite here (It says that it is inclusive.) Is it because SE 6 differs from SE 7?
Edit: Java the Complete Reference 7th edition discussed SE 6.
Upvotes: 1
Views: 1638
Reputation: 2036
In the specification, they use the word "subtype" in parametrization to mean inclusive subtype. In section 4.10, it defines the phrase "proper subtype/proper supertype" to mean exclusive subtype/supertype while "subtype/supertype" means inclusive subtype/supertype.
Upvotes: 1
Reputation: 19224
The bound is inclusive.
It is very easy to try it by yourself:
import java.util.*;
import java.lang.*;
class Main {
public static void main (String[] args) throws java.lang.Exception {
addNumbers(new ArrayList<Integer>());
}
public static void addNumbers(List<? super Integer> list) {
for (int i = 1; i <= 10; i++) {
list.add(i);
}
}
}
Upvotes: 2