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 realize List Classification Statistics of Java set

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "how to achieve Java set List classification statistics". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Java collection List classification statistics

Requirements: the third-party interface requests to return the collection for type statistics

Private static final String EIGHTASKS_CARD_URL= "/ api/hzzvue/user/getBdrwTjfxData"; @ Autowired private HuayuInterfaceClient huayuInterfaceClient; public Map getEightasksType () {Map paramMap=new HashMap (); paramMap.put ("type", ""); JSONObject jsonObeject=huayuInterfaceClient.getHuayuInterface (paramMap, EIGHTASKS_CARD_URL); List list=null If (json ObejectNull) {list= (List) jsonObeject.get ("list");} Map resultMap=new HashMap () If (list.size () > 0 & & listings for null) {list.stream () .Collectors.groupingBy (map-> map.get ("type")) .forEach ((keyType) Typelist)-> {if ("Water pollution Prevention" .equals (keyType) | | "Water Shoreline Protection" .equals (keyType) | | "Water Environment Control" .equals (keyType) | | "long-term Management and Protection" .equals (keyType) | "Water Resources Protection" .equals (keyType) | | "Law Enforcement Supervision" .equals (keyType) | | "Aquatic ecological restoration" .equals (keyType) | | "promoting water culture" .equals (keyType) {resultMap.put ((String) keyType) Typelist.size () }});} return resultMap;}

Results:

{"code": 0, "msg": "success", "data": {"Water Resources Protection": 23, "Law Enforcement Supervision": 31, "Water Ecological Restoration": 31, "Water Environment Control": 30, "Water Culture Promotion": 16, "Water Shoreline Protection": 26, "long-term Management and Protection": 32 This is the content of "Water pollution Prevention and Control": 31}} "how to realize Java set List Classification Statistics". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Development

Wechat

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

12
Report