>>why did the wrapper classes had to be immutable? I didn't figure out what is it going to buy us
In this example, we store pairs of integers and Objects in a container. The container can hold only Objects, not primitive values. So we wrap the integer in an Integer. The key is unique. The key must not change. We want the key to be immutable.
�The second purpose of wrappers is to create objects to hold values of a primitive type for generically written classes that know only how to handle Object references.�
The
Java Programming Language 11.1, Arnold, Gosling, Holmes
[ March 29, 2003: Message edited by: Marlene Miller ]