泛型是什么 <?>其实是什么意思? [英] Generics what does <?> actually mean?
本文介绍了泛型是什么 <?>其实是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能的重复:
List 是什么>在 Java 泛型中是什么意思?
Java泛型类型中的问号是什么参数是什么意思?
抱歉,尝试搜索 >
很困难.
Apologies but it was difficult trying to search for <?>
.
Java 泛型是什么意思?我理解 和
,但我以前从未见过这个问号.
What does mean in regards to Java generics? I understand <A extends B>
and <A super B>
, but I have never seen this question mark on its own before.
推荐答案
>
是 ,它也被称为无界通配符.因此,您可以在泛型中指定任何类型的对象.
<?>
is a shorthand for <? extends Object>
, it's also known as an unbounded wildcard. So you can specify any type of object in your generic.
例如,List
类被声明为 List>
,因为它可以是任何你想要的列表.
For example the List
class is declared as List<?>
, because it can be a list of anything you want.
资源:
这篇关于泛型是什么 <?>其实是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文