Java program to check whether the specified Class object represents an array or not
// Java program to check the specified Class object
// represents an array
public class Main {
public static void main(String[] args) throws ClassNotFoundException {
int arr[] = new int[5];
Class cls1 = arr.getClass();
Class cls2 = float.class;
boolean res1 = cls1.isArray();
boolean res2 = cls2.isArray();
System.out.println("Is " + cls1 + " an array : " + res1);
System.out.println("Is " + cls2 + " an array : " + res2);
}
}
Output
Is class [I an array : true
Is float an array : false