I have two types of objects in my application, where each object of one kind has exactly one corresponding object of another type.
The obvious choice to track this relationship is Map<type1, type2> , like HashMap. But for some reason I'm suspicious. Can I use the object as a key on the card, transfer it, go to another collection and at any time get its partner from the Card?
After creating the object, everything I look at is an identifier, right? So, probably, there are no problems. What if i serialize and deserialize the key?
Any other reservations? Should I use something else to correlate pairs of objects, like a number that I myself generate?
java collections maps
Hanno fietz
source share