SE450
:
The ArrayStoreException
[11/86]
Rectangle[]
is a subtype of
Shape[]
Can assign
Rectangle[]
value to
Shape[]
variable:
Rectangle[] r = new Rectangle[10];
Shape[] s = r;
Both
r
and
s
are references to the same array
That array holds rectangles
The assignment
s[0] = new Polygon();
compiles
Throws an
ArrayStoreException
at runtime
Each array remembers its component type