标签:ecif sel this string list import which util self
(1)<? super String>
is any class which is a superclass of String
(including String
itself). (In this case, the only other suitable class is Object
.)
即包括String的父类和它本身的类。
(2) <? extends String>
(which in this specific case wouldn‘t be very useful as String
is final
, so it can have no subclasses).
即包括String的子类,而String没有子类,为null。
QUESTION 217 Given:
3. import java.util.*;
4. public class Hancock {
5. // insert code here
6. list.add("foo");
7. }
8. }
Which two code fragments, inserted independently at line 5, will compile without warnings? (Choose two.)
A. public void addStrings(List list) {
B. public void addStrings(List<String> list) {
C. public void addStrings(List<? super String> list) {
D. public void addStrings(List<? extends String> list) {
Answer: BC
java泛型中<? super String>和<? extends String> 的区别
标签:ecif sel this string list import which util self
原文地址:http://www.cnblogs.com/bincoding/p/6666666.html