Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Java: hashmap.remove(key)

Avatar of JianJunShen
JianJunShen asked on
7 Comments1 Solution323 ViewsLast Modified:
Hi: I have a data structure. In the data structure, I have five hashmaps. IN every hashmap, there is key and value pair. May I put 5 hashmap keys all point to same object. I put hashmap1.put(key1, sameobject), hashmap2.put(key2,sameobject), hashmap3.put(key3, sameobject)....

When I remove it, I remove hashmap1.remove(key1), hashmap2.remove(key2), hashmap3.remove(key3),... does that mean
1) In  hashmapX.remove(keyX):..... I only delete reference. Garbage collection will remove sameobject.
2) In hashmap1.remove(key1), I already removed sameobject, all other keys are dead. Hence memory leak comes.

Which case 1), 2) is true?
Avatar of CEHJ
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answers