ufheasuhewauhjdfuiewhufujqWU8OIU9OQEOIGUE9IFFOPTEO9FQIFO9WR0WSQFFEFTEAQFRESFGAEFED
4条回答
- lbcab 2016-05-20 04:50关注
public static void main(String[] args) { String str = "It's the first day of class, and the room is buzzing with excitement and expectation,curiosity and uncertainty"; String[] strArrs = str.split(" "); HashMap<String, Integer> map = new HashMap<String, Integer>(); for (int i = 0; i < strArrs.length; i++) { if (map.get(strArrs[i]) != null) { Integer integer = map.get(strArrs[i]); integer++; map.put(strArrs[i], integer); } else { map.put(strArrs[i], 1); } } int maxNum = 0; String maxValue = null; for (int i = 0; i < strArrs.length; i++) { int tmp = map.get(strArrs[i]); if(tmp > maxNum) { maxNum = tmp; maxValue = strArrs[i]; } } System.out.println(maxValue + " : " + maxNum); }
解决 无用评论 打赏 举报
悬赏问题
- ¥15 安装svn网络有问题怎么办
- ¥15 Python爬取指定微博话题下的内容,保存为txt
- ¥15 vue2登录调用后端接口如何实现
- ¥65 永磁型步进电机PID算法
- ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
- ¥88 找成都本地经验丰富懂小程序开发的技术大咖
- ¥15 如何处理复杂数据表格的除法运算
- ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
- ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
- ¥15 latex怎么处理论文引理引用参考文献