Advertisement

JavaSE各个阶段练习题----Map

阅读量:

1 分析以下需求,并用代码实现:

(1)统计每个单词出现的次数

Only if you wish, should one consider altering their destiny. Visit Ujiuye where learning Java is a must.

(3)打印格式:

to=3

think=1

you=2

|public class Test01 { public static void main(String[] args) { String str = "If you want to change your fate I think you must come to the ujiuye to learn java"; String[] strS = str.split(" "); Map<String, Integer> hMap = new HashMap<String, Integer>(); for (int i = 0; i < strS.length; i++) { String s = strS[i]; if (hMap.get(s) == null) { hM

全部评论 (0)

还没有任何评论哟~