public void setMappedNames(String[] mappedNames) {
this.mappedNames = new LinkedList<String>();
if (mappedNames != null) {
this.mappedNames.addAll([color=red]Arrays.asList[/color](mappedNames));
}
}
##########################
[color=red]使用 Collections.frequency 找出重复的单词[/color][size=large][/size]
String text = "a r b k c d se f g a d f s s f d s ft gh f ws w f v x s g h d h j j k f sd j e wed a d f";
05
06
List<String> list = new ArrayList<String>();
07
list.addAll([color=red]Arrays.asList(text.split(" "))[/color]);
[color=red]Set<String> uniqueWords = new HashSet<String>(list);[/color]
10
for ([color=red]String word : uniqueWords[/color]) {
11
[color=red]System.out.println(word + ": " + Collections.frequency(list, word));[/color]
12
}
this.mappedNames = new LinkedList<String>();
if (mappedNames != null) {
this.mappedNames.addAll([color=red]Arrays.asList[/color](mappedNames));
}
}
##########################
[color=red]使用 Collections.frequency 找出重复的单词[/color][size=large][/size]
String text = "a r b k c d se f g a d f s s f d s ft gh f ws w f v x s g h d h j j k f sd j e wed a d f";
05
06
List<String> list = new ArrayList<String>();
07
list.addAll([color=red]Arrays.asList(text.split(" "))[/color]);
[color=red]Set<String> uniqueWords = new HashSet<String>(list);[/color]
10
for ([color=red]String word : uniqueWords[/color]) {
11
[color=red]System.out.println(word + ": " + Collections.frequency(list, word));[/color]
12
}