Java泛型 - 获取和放置原则异常

时间:2016-01-06 00:38:39

标签: java list generics collections wildcard

我目前正在为编程课程学习泛型,在阅读过去的试卷时,我遇到了这个问题:

Give an example of a wildcard definition we might use when we want to get items from a collection object? Give a wildcard definition we might use when we wish to put items into a collection? What are the exceptions in each case?

我知道扩展通配符(?extends T)应该用于从集合对象中“获取”值,并且应该使用超级通配符(?super T)将值“放入”集合对象中,但是是例外吗?

0 个答案:

没有答案