int primitivI[] = {1,1,1};
Integer wrapperI[] = {2,22,2};
1. System.out.println(primitivI instanceof Object);//true
2. System.out.println(primitivI instanceof Object[]);//Compilation Error Why ????
3. System.out.println(wrapperI instanceof Object);//true
4. System.out.println(wrapperI instanceof Object[]);//true
Here I have two arrays of integer (primitve,Wrapper) type but I have got different result for instanceof operator
see the line number 2 and 4
line no 4 will compile successfully and give result true but in case of line 2, why does it result in a compilation error?
From line 1 and 3 it is clear that the two arrays are instanceof object but in case of Object[]
, why do the
results differ?