Java Class getComponentType() Method

21 Mar 2025 | 1 min read

The getComponentType() method of java Class returns the class representing the component type of an array. Otherwise this method return null.

Syntax

Parameter

NA

Returns

Class representing the component type.

Throws

This does not throw an exception.

Example 1

Output:

 The componentType = java.lang.String 

Example 2

Output:

 int class java.lang.String class java.lang.Void null 
 
Next TopicJava Class