Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Collections;
  3. import java.util.HashSet;
  4. import java.util.List;
  5. import java.util.Set;
  6.  
  7. /**
  8. *
  9. * @author jakub
  10. */
  11. public class Test2 {
  12.  
  13. /**
  14. * @param args the command line arguments
  15. */
  16. public static void main(String[] args) {
  17. 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";
  18.  
  19. List<String> list = Arrays.asList(text.split(" "));
  20.  
  21. Set<String> uniqueWords = new HashSet<>(list);
  22. for (String word : uniqueWords)
  23. System.out.println(word + ": " + Collections.frequency(list, word));
  24.  
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement