`

java code (1)

 
阅读更多
public void setMappedNames(String[] mappedNames) {
this.mappedNames = new LinkedList<String>();
if (mappedNames != null) {
this.mappedNames.addAll(Arrays.asList(mappedNames));
}
}



##########################

使用 Collections.frequency 找出重复的单词[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(Arrays.asList(text.split(" ")));
Set<String> uniqueWords = new HashSet<String>(list);
10
for (String word : uniqueWords) {
11
System.out.println(word + ": " + Collections.frequency(list, word));
12
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics