H
HK
Arrays already have fully type-safe types.
<typename>[ ] <ID> = new <typename>[ <arrayLen> ];
Not sure I follow. I want to implement a parameterized stack
with an array so that the client can write cast-free code [...]
This is possible with generics, but the implementation of
ArrayStack seems to require a cast somewhere.
The code of java.util.HashMap contains the equivalent of this:
public class Bla<T> {
Entry[] table; // raw type used as array element
public void do() {
// assignment from (raw) array element to fully typed variable
Entry<T> e = table[0];
}
// type entry class used to hold elements
static class Entry<Q> {
Q value;
}
}
This seems to indicate that even java.util.HashMap does not
compile without a warning. Is that true?
Harald.