This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Reference or just a copy? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reference or just a copy?" Watch "Reference or just a copy?" New topic

Reference or just a copy?

David Duran
Ranch Hand

Joined: Feb 11, 2002
Posts: 122
If I do a get out of a hashtable and modify a member variable of the returned object, will that modification be mirrored in the hashtable or do I have to do a 'put' again?
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
The hashtable returns a reference to the original object, not a copy - so it's been modified now. No need for a put.

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: Reference or just a copy?