我正在阅读该类的APIArrayType
,它是ASTNode
.
有一种方法getComponentType()
,一种方法getElementType()
。
对于Statement
: int[] list = new int[50]
,上述两种方法都返回类型 - int
。
有谁知道这两种方法之间的区别可能是?
我正在阅读该类的APIArrayType
,它是ASTNode
.
有一种方法getComponentType()
,一种方法getElementType()
。
对于Statement
: int[] list = new int[50]
,上述两种方法都返回类型 - int
。
有谁知道这两种方法之间的区别可能是?
The Javadoc has a table with brief descriptions, but you have to scroll down to read the full explanations. For getComponentType()
, it says:
Returns the component type of this array type. The component type may be another array type.
whereas for getElementType()
, it says:
Returns the element type of this array type. The element type is never an array type.
This is a convenience method that descends a chain of nested array types until it reaches a non-array type.
So, for example, an int[][]
would have a "component type" of int[]
, but an "element type" of int
.