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.
publicclass MainClass {
publicstaticvoid main(String[] argv) {
int[] intArray = newint[2];
if (intArray instanceofint[]) {
System.out.println("it is an int array");
}
if (intArray instanceoffloat[]) {
System.out.println("it is a float array");
}
}
}
Incompatible conditional operand types int[] and float[]