ArrayDS requires all its members to have the same time. Java throws an ArrayStoreException when an attempt has been made to store the wrong type of an object in an array of objects. Do not remember what does C++.
I correctly understand that it is important to have all objects of the same type in the array , because it guarantees constant access to the time element through the following two operations:
1) element size * element index = offset
2) array pointer address + offset
If the objects have different types and therefore different sizes, the above formula will not work.
source
share