Java Reflection Java Java API
java.lang.Class
public Class<?> getComponentType()
Returns the Class representing the component type of an array. If this class does not represent an array class this method returns null.
Class
package com.logicbig.example.clazz;public class GetComponentTypeExample { public static void main(String... args) { int[] ints = {}; System.out.println(ints.getClass().getComponentType()); System.out.println(String[].class.getComponentType()); Void[] voids = {}; System.out.println(voids.getClass().getComponentType()); System.out.println(String.class.getComponentType()); }}
intclass java.lang.Stringclass java.lang.Voidnull