public class Sorting2 {
/**
* 1、分割字符串(按照空格来切割) 2、分拣存储 3、按要求查看 单词出现的次数 4、加入面向对象
*/
public static void main(String[] args) {
// 1、分割字符串(按照空格来切割)
String str = "this is a cat and that is a mice and where is the food";
String[] arr = str.split(" ");
// 2、分拣存储
Map<String, Letter> map = new HashMap<String, Letter>();
for (String key : arr) {
if (!map.containsKey(key)
HashMap分拣存储2:统计每个单词出现的次数(采用面向对象)
最新推荐文章于 2022-10-30 22:41:58 发布