DRAFT
Observed
Elements of arrays are untyped
The type of an array specifies the type of the elements
The following code is illegal:
int[] a = new int[3];
a[0] = "Hi"; // type error
a[1] = 12;
a[2] = 13.5; // type error
Like everything in Java, arrays are strongly typed. If we have an array of type int[]
, we can only assign values of type int
to its elements.
Follow us on twitter to hear about new misconceptions.