Difference between Object[] and Array of specific Objects in java

Car[] can contain only Car instances, or sub-classes of Car instances.
If you were to have a class like this: class Honda extends Car , Honda instances can be populated in the Car array as well, because Honda extends from Car.

Object[] can contain any Object instances, or any subclass of Object (every class in Java is a subclass Object, even if it is not explicitly stated with an extends keyword in a custom class), so any instance in java can be populated in the Object array.

Leave a Comment