This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Actually I have 10000 objects and I need to put hem in to a map and use them as Key. It may be 10 millions. My question is there any way I can save myself from creating so many objects ....I am worried about the performance.
When you use an object as a key in a HashMap, the object's state must not change as long as it is used as a key. If the object's state changes in a way so that the hash code of the object changes, then the HashMap will get confused and won't work properly anymore. It's safest to use only immutable objects as keys in a HashMap.
So, you cannot use a mutable object like this, for example: