GC, strange question!
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
#181 The presence of a mapping for a given key withinthis collection instance will not prevent the keyfrom being recycled by the garbage collector.
Which concrete class provides the specified features?
(1) Vector
(2) Hashtable
(3) TreeMap
(4) TreeSet
(5) HashMap
(6) HashSet
(7) WeakHashMap
(8) None of the above
Please Help!
I am not able, how to interpret this question!
Regards,
cmbhatt
cmbhatt
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
"A hashtable-based Map implementation with weak keys. An entry in a WeakHashMap will automatically be removed when its key is no longer in ordinary use. More precisely, the presence of a mapping for a given key will not prevent the key from being discarded by the garbage collector, that is, made finalizable, finalized, and then reclaimed. When a key has been discarded its entry is effectively removed from the map, so this class behaves somewhat differently than other Map implementations. "
Am I correct?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Am I correct?
yah , WeakHashMap is the correct answer because
its remove keys that no longer used and make them available for GC
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
COULD ANYBODY PLEASE GIVE ME A LITTLE EXAMPLE OF THAT???
Henry, Barry where are you?
Regards,
cmbhatt
cmbhatt
-
-
Number of slices to send:Optional 'thank-you' note:
-
-

[ April 22, 2007: Message edited by: Barry Gaunt ]
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
WeakHashMap is an implementation of the Map interface that stores only weak references to its keys. Storing only weak references allows a key-value pair to be garbage-collected when its key is no longer referenced outside of the WeakHashMap. This class provides the easiest way to harness the power of weak references. It is useful for implementing "registry-like" data structures, where the utility of an entry vanishes when its key is no longer reachable by any thread.
What are weak references?
What I understood and what I did is as following:
cmbhatt
| To do a great right, do a little wrong - shakepeare. twisted little ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |









