Robert

40%
Flag icon
A Favorites instance is typesafe: it will never return an Integer when you ask it for a String. It is also heterogeneous: unlike an ordinary map, all the keys are of different types. Therefore, we call Favorites a typesafe heterogeneous container.
Robert
I don't like this pattern. You're basically creating a path for consumer errors to be silent. That is, if the user put in a string then tried to get an int, it just returns 'null' rather than failing, which is likely to cause confusion or even go unnoticed (by the developer, but noticed by end users) longer.
Effective Java: A Programming Language Guide (Java Series)
Rate this book
Clear rating
Open Preview