In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to use WeakHashMap in Java? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
1. Overview of the WeakHashMap class
WeakHashMap is a weak key implemented based on the Map interface of the Hash table. When its key is no longer in normal use, the entry in the entry is automatically deleted. Null values and null values are supported. This class has similar performance characteristics to the HashMap class and has the same efficiency parameters as the initial capacity and load factor. Like most collection classes, this class is out of sync. You can use the following to construct synchronous WeakHashMap WeakHashMap Collections.synchronizedMap methods. Weak reference-if the only reference to an object is a weak reference, the garbage collector can reclaim the object's memory at any time. It doesn't have to wait until the system runs out of memory. Typically, it will be released the next time the garbage collector runs. This class is a member of Java Collections Framework.
2. WeakHashMap class constructor
WeakHashMap ()-WeakHashMap uses the default initial capacity (16) and load factor (0. 75) to construct a new null.
WeakHashMap (int initialCapacity)-WeakHashMap constructs a new null with the given initial capacity and default load factor of0.75.
WeakHashMap (int initialCapacity, float loadFactor)-WeakHashMap constructs a new null with a given initial capacity and a given load factor.
WeakHashMap (Map
< ?extends K,? extends V>M)-constructs a new whose WeakHashMap has the same mapping as the specified mapping.
3. WeakHashMap class method
Void clear ()-removes all mappings from this mapping.
Boolean containsKey (Object key)-returns true if this mapping contains a mapping for the specified key.
Boolean containsValue (Object value)-returns true if this mapping maps one or more keys to the specified value.
SetentrySet ()-returns a Set view of the mappings contained in this mapping.
Void forEach (BiConsumer
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.