Keep bounded wildcards out of return values.
不要对返回值使用通配符。
The biggest impediment to using bounded wildcards correctly is the perception that we don't need to use them!
正确使用有界通配符的最大绊脚石是认为没有必要使用它们。
Some situations will call for lower-bounded wildcards, and some for upper-bounded ones, and the get-put principle can be used to determine which should be used.
有些情况适合使用下限通配符,而另一些情况则适合使用上限通配符,通过get - put原则可以判断应该使用哪种通配符。
Lower-bounded wildcards show up when you want to specify a callback object, such as a comparator, or a data structure into which you are going to place a value.
当您希望指定一个回调对象(例如一个比较器)或存放某个值的数据结构,可以使用下限通配符。
Bounded wildcards work best when they are used in APIs, not in client code.
有界通配符最适合用于API,而不是客户机代码。
Bounded wildcards are extremely useful in making generic APIs more flexible.
有界通配符对于提高泛型api的灵活性极其有用。
Bounded wildcards are extremely useful in making generic APIs more flexible.
有界通配符对于提高泛型api的灵活性极其有用。
应用推荐