import java.util.*;
public class WorldCount {
public static void main(String[] args) {
Map map = new HashMap
while (true) {
Scanner sc = new Scanner(System.in);
System.out.println("please input:");
String word = sc.nextLine();
if (map.containsKey(word)) {
Integer value = (Integer) map.get(word);
value++;
map.put(word, value);
} else {
map.put(word, 1);
}
Set
for (String key : keySet) {
Integer value = (Integer) map.get(key);
System.out.print(key + " " + value + " n");
}
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)