标签:str set pack package read static div dmi class
package javaClassHomework; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.TreeMap; public class statistics { public static void main(String [] args) throws IOException { BufferedReader br=new BufferedReader(new FileReader("C:\\Users\\Administrator\\Desktop\\kkk.txt")); int c; TreeMap<String,Integer> hm=new TreeMap<>(); String line; int kt=0; while((line=br.readLine())!=null) { String [] str=line.split("[^a-zA-Z]"); for(int i=0;i<str.length;i++) { if(!str[i].equals("")) { hm.put(str[i],hm.containsKey(str[i])?hm.get(str[i])+1:1);} } } br.close(); int max=0; for(String k: hm.keySet()) { if(hm.get(k)>=max) { max=hm.get(k); } } for(String k: hm.keySet()) { if(hm.get(k)==max) { System.out.println(k+":"+hm.get(k)); } } }}
标签:str set pack package read static div dmi class
原文地址:https://www.cnblogs.com/yanwenhui/p/11595025.html