package example;
import java.util.*;
/**
* Created by TR_VMHyper on 2016/8/17.
*/
public class Test {
public static void main(String[]args){
/**
* 面试题:统计一篇文章中出现单词出现的次数
*/
String str="Do be a good student and also to be a good boy . The beautiful girl i hope to marry with you . It's my dream. Dream for dream ...";
String[]sts=str.split(" ");
Map map=new HashMap();
for (String s : sts) {
if (map.containsKey(s.toLowerCase())){
map.put(s.toLowerCase(),map.get(s.toLowerCase())+1);
}else{
map.put(s.toLowerCase(),1);
}
}
int max=0;
//System.out.println(map.entrySet());
Set>ks= map.entrySet();
List>ins=new ArrayList>(ks);
Collections.sort(ins, n