package cn.rrl.interview;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.TreeSet;
/**
* 计算一段文本中出现英语单词次数最多的单词
* @author Mr.xiao
*
*/
public class HelloCountWord {
/**
* @param args
*/
public static void main(String[] args) {
String str = "But you you by the end of the year,look to the skies above London and you'll see the usual suspects raninclouds,planes and pigeons.you might just see something else.";
TreeSet<String> re = ChangeTheWord(str);//把单词转换成 (次数:单词) 的格式 放入TreeSet中
ArrayList<String> results = getTheMax(re);//得到TreeSet中的最大值,以及一样大的值
for(String result : results){ //
System.out.println(result);
}
}
/**
* 得到TreeSet中的最大值,以及一样大的值
* @param re
* @return
*/
public static ArrayList<String> getTheMax(Tr
使用java,计算一段文本中出现英语单词次数最多的单词
最新推荐文章于 2023-03-17 21:17:39 发布