Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to analyze whether Map key value is empty or not

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

How to analyze whether Map key value is empty or not, I believe that many inexperienced people are at a loss about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Neither Key nor Value of ConcurrentHashMap can be null, but HashMap can. Do you know the reason for this design?

It is debatable whether it is a correct way for ordinary Map to allow null, which will increase the possibility of making mistakes.

The old man ConcurrentHashMap only said that if value is empty, it will be ambiguous.

That is, in the case of thread safety, did he set up a null or did he not have such a thing at all?

Key is the same thing. Besides, I agree with him more.

Do the Key and Value of Map such as TreeMap and Hashtable support null?

Because TreeMap is based on compare, null values cannot be compare.

Value can be null, TreeMap is not thread safe

Key of TreeMap cannot be empty

Hashtable's Key and Value can not be empty, I think the principle should be the same as ConcurrentHashMap.

After reading the above, have you mastered the method of analyzing whether the Map key value is empty or not? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report