Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize List Classification Statistics of Java set

Shulou Source: shulou.com Published: 2022-06-03 07:11:44 10月02日 Update

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!

Tags: Statistics protection classification content shoreline law enforcement supervision more water area hydrology water culture water pollution water environment water resources ecology knowledge water resources law enforcement supervision pr Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux NVidia Shulou Tech Info MySQL Docker