java统计集合中每个元素出现的次数

        Map<Integer, Integer> mapNum = new HashMap<>();
        for (Map<String, Object> edge : edges) {
            Integer source = Integer.valueOf(edge.get("source").toString());
            Integer target = Integer.valueOf(edge.get("target").toString());
            Integer count1 = mapNum.get(source);
            Integer count2 = mapNum.get(target);
            mapNum.put(source, (count1 == null) ? 1 : count1 + 1);
            mapNum.put(target, (count2 == null) ? 1 : count2 + 1);
        }
上一篇:React hooks函数的使用方法


下一篇:Protocol "‘https" not supported or disabled in libcurl