前言 从Map取值,根据获取的类型进行统计,若有则+1,若无则新增新的分类纯属灵机一动 步骤 for (String str : stringList) { int count=typeMap.getOrDefault(str,0); typeMap.put(str,++count); }