Robert

38%
Flag icon
In other words, the Map does not guarantee the type relationship between keys and values, which is that every value is of the type represented by its key. In fact, Java’s type system is not powerful enough to express this. But we know that it’s true, and we take advantage of it when the time comes to retrieve a favorite.
Robert
Well, we "know it's true," here, but in a more distant spot (far away when this class becomes large) we could put in a value that doesn't fit the key class, and generics/compiler couldn't protect from that case.
Effective Java
Rate this book
Clear rating
Open Preview