SCJP 5.0, SCWCD 5.0, SCBCD 5.0
ben oliver wrote:what I want to do is -- First I need to put "order" object into map, then I need to retrieve it out and make some change and put it back using a different key.
But by doing this way, I think I am also altering the original "order" object
so next time when I do map.get("john") I would get a different object, which is NOT what I want.
I want to keep the value for key of "john", take it out, maybe create another duplicated one and change on that new one and put it into map with a new key.
but I just don't know how. Any help ?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
ben oliver wrote:
1. I don't need to worry how complex the "LineItem" is and just need to do the above, correct ?
2. Does "order" object's "item" points to the same object "anotherOrder" object's "item" ? That scares me most.
ben oliver wrote:Thanks so much for the reply...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Dennis Deems wrote:For this use case I think a Factory makes better sense than a copy constructor. Use of a copy constructor really ought to be limited to cases in which we really do want an honest-to-goodness copy.
Destiny's powerful hand has made the bed of my future. And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|