问题描述
您能否帮我理解无界通配符列表和原始类型列表之间的区别?
列表与LT;?> b; //无界通配符类型
列出a; //原始类型
除此之外,任何人都可以帮助我理解什么是一个有界的类型参数列表?
List< E extends Number> C;
以下是三个概要:
-
List
:没有类型参数的列表。这是一个列表,其元素可以是任何类型 - 元素可以是不同的类型 。 -
List<?>
:带有无限类型参数的列表。它的元素是一个特定的,但未知的类型; 元素必须全部是相同的类型。 $ c>:一个名为
T
的类型参数列表。提供的 T
类型必须是一个扩展 E
的类型,或者它不是该参数的有效类型。 Could you help me understand the difference between unbounded wildcard type List and raw type List?
List<?> b; // unbounded wildcard type
List a; // raw type
Along with this can anybody help me understand what is a bounded type parameter list?
List<E extends Number> c;
Here's a summary of the three:
List
: A list with no type parameter. It is a list whose elements are of any type -- the elements may be of different types.List<?>
: A list with an unbounded type parameter. Its elements are of a specific, but unknown, type; the elements must all be the same type.List<T extends E>
: A list with a type parameter calledT
. The supplied type forT
must be of a type that extendsE
, or it is not a valid type for the parameter.
这篇关于无界通配符类型List<>的区别是什么?和原始类型列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!