Object[]
can store any object from any class because every class in Java extends java.lang.Object
.
I don't think primitives extend from Object
, so why can we store them like the following?
Object[] obj_arr = {1, 2, 1.2, 'a', false, new MyClass(), null};
The question is why can primitives be stored in an Object array and did Auto boxing happen or not in the above code?