instanceof checks whether the object is an array.
instanceof checks whether the element type of that array is some subclass of the element type
of the right argument.
public class MainClass {
public static void main(String[] argv) {
int[] intArray = new int[2];
if (intArray instanceof int[]) {
System.out.println("it is an int array");
}
if (intArray instanceof float[]) {
System.out.println("it is a float array");
}
}
}
|