G
Googmeister
My understanding is that the underlying reason is that arrays are
"covariant" but generics are not. In other words, String[] is a subtype
of
Comparable[], but List<String> is not a subtype of List<Comparable>.
In a world without generics, covariant arrays are useful, e.g., to
implement Arrays.sort(Comparable[]) and have it be callable with an
input of type String[]. But now that Java has generics, the usefulness
of covariant arrays is diminished, but we are stuck with them.
"covariant" but generics are not. In other words, String[] is a subtype
of
Comparable[], but List<String> is not a subtype of List<Comparable>.
In a world without generics, covariant arrays are useful, e.g., to
implement Arrays.sort(Comparable[]) and have it be callable with an
input of type String[]. But now that Java has generics, the usefulness
of covariant arrays is diminished, but we are stuck with them.