public class Test {
public void index() {
String strWords = "Hello World My First Unit Test";
String[] words_Array = strWords.split(" ");
Map<String,Integer> words_Map=new HashMap<String, Integer>();
int arrLength = words_Array.length;
for(int i=0;i<arrLength;i++){
if(!words_Map.containsKey(words_Array[i])){
words_Map.put(words_Array[i], 1);
System.out.println(words_Array[i]);
System.out.println("出现");
System.out.println(words_Map.put(words_Array[i], 1));
System.out.println("次");
}else{
int currentNum = words_Map.get(words_Array[i])+1;
words_Map.remove(words_Array[i]);
words_Map.put(words_Array[i], currentNum);
System.out.println(words_Array[i]);
System.out.println("出现");
System.out.println(words_Map.put(words_Array[i], currentNum));
System.out.println("次");
}
}
}
}