Fork me on GitHub
#java
<
2021-08-05
>
Ben Sless16:08:17

I'm trying to understand the difference, if there is one, between an array of objects and named classes, i.e. Object[] vs. MyClass[], in terms of memory layout and performance differences. From what I read, arrays of non primitive types hold only references

seancorfield17:08:05

I believe the difference only exists in the type system (and controls polymorphism around updates and access to the contained objects).

emccue18:08:24

if you make an array of MyClass[] there will be runtime verification of the types of elements

emccue18:08:38

even if you turn it into Object[] in the type system

seancorfield18:08:33

Yeah, one of the few runtime type checks that is built into the JVM, right?