Interface ArrayType

All Superinterfaces:
AnnotationTarget, Type

public interface ArrayType extends Type
An array type is created from a component type. For a component type T, the array type is written T[]. A component type may itself be an array type. For a component type T[], the array type is written T[][]. Such array type is also called multi-dimensional array type.

Array types also have an element type, which is obtained by repeatedly asking for the component type until a non-array type is returned. For example, the String[][] array type has an element type of String.

Since:
4.0
  • Method Details

    • componentType

      Type componentType()
      Returns the component type of this array type, as defined by The Java™ Language Specification. That is, in case of a single-dimensional array, the element type of the array, and in case of a multi-dimensional array, an array type with one less dimension.

      For example, the component type of int[] is the int type. The component type of String[][] is the String[] array type, whose component type is the String type.

      Each dimension of the array type may be annotated independently.

      Returns:
      the component type, never null
    • kind

      default Type.Kind kind()
      Description copied from interface: Type
      Returns the kind of this type.
      Specified by:
      kind in interface Type
      Returns:
      the kind of this type
    • asArray

      default ArrayType asArray()
      Description copied from interface: Type
      Returns this type as an array type.
      Specified by:
      asArray in interface Type
      Returns:
      this array type, never null