|
|
|
|||
|
Retrieving Component TypesThe component type is the type of an array's elements. For example, the component type of thearrowKeys array in the following line of code is
Button:
The component type of a multidimensional array is an array. In the next line of code, the component type of the array namedButton[] arrowKeys = new Button[4]; matrix is int[]:
By invoking theint[][] matrix = new int[100][100]; getComponentType method against the Class object that
represents an array, you can retrieve the component type of the array's
elements.
The sample program that follows invokes the
The output of the sample program is:
Array: [I, Component: int Array: [Ljava.awt.Button;, Component: java.awt.Button Array: [[Ljava.lang.String;, Component: [Ljava.lang.String; | |||
|