Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. Map<String, Integer> stringsWithCount = new TreeMap<String,Integer>();
  2. for (Message msg : convInfo.messages) {
  3. // where ever your input comes from: turn it into lower case,
  4. // so that "ccc" and "CCC" go for the same counter
  5. String item = msg.userName;
  6. if (stringsWithCount.containsKey(item)) {
  7. stringsWithCount.put(item, stringsWithCount.get(item) + 1);
  8. } else {
  9. stringsWithCount.put(item, 1);
  10. }
  11. }
  12.  
  13. for (Entry<String, Integer> entry : stringsWithCount.entrySet()) {
  14.  
  15. System.out.println(entry.getKey()+"("+entry.getValue()+")");
  16. }
  17.  
  18. G_LO(1)
  19. FCHAN95(1)
  20. G_LO(1)
  21. FCHAN95(2)
  22. G_LO(1)
  23. FCHAN95(2)
  24. G_LO(1)
  25. WVU(1)
  26. FCHAN95(2)
  27. G_LO(1)
  28. SWONG00(1)
  29. WVU(1)
  30. FCHAN95(3)
  31. G_LO(1)
  32. SWONG00(1)
  33. WVU(1)
  34. FCHAN95(4)
  35. G_LO(1)
  36. SWONG00(1)
  37. WVU(1)
  38. FCHAN95(5)
  39. G_LO(1)
  40. SWONG00(1)
  41. WVU(1)
  42. FCHAN95(6)
  43. G_LO(1)
  44. SWONG00(1)
  45. WVU(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement