注1(1)注2
!!!!!
10
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import parator; import java.util.HashMap; import java.util.List; import java.util.Map; public class nd2question { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String S = ""; while(true){ String s = in.readLine(); if (!"!!!!!".equals(s)) { S += s + " "; } else break; } S = S.replaceAll("( )+", " "); String str[] = S.split(" "); System.out.println(str.length); Map map = new HashMap(); for (String s1 : str) { if (!map.containsKey(s1)) map.put(s1, 1); else map.put(s1, (map.get(s1)+1)); } List> list = new ArrayList>(map.entrySet()); Collections.sort(list, new Comparator>() { public int compare(Map.Entry mapping2, Map.Entry mapping1) { return mapping1.getValue().compareTo(mapping2.getValue()); } }); Map.Entry mapping = null; for (int i = 0 ;i
java统计每个单词单词出现的次数_(java)统计若干段英文中的单词数量 并统计每个单词出现的次数按降序排序。...
如果觉得《java统计每个单词单词出现的次数_(java)统计若干段英文中的单词数量 并统计每个单》对你有帮助,请点赞、收藏,并留下你的观点哦!