Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Map<String, Integer> stringsWithCount = new TreeMap<String,Integer>();
- for (Message msg : convInfo.messages) {
- // where ever your input comes from: turn it into lower case,
- // so that "ccc" and "CCC" go for the same counter
- String item = msg.userName;
- if (stringsWithCount.containsKey(item)) {
- stringsWithCount.put(item, stringsWithCount.get(item) + 1);
- } else {
- stringsWithCount.put(item, 1);
- }
- }
- for (Entry<String, Integer> entry : stringsWithCount.entrySet()) {
- System.out.println(entry.getKey()+"("+entry.getValue()+")");
- }
- G_LO(1)
- FCHAN95(1)
- G_LO(1)
- FCHAN95(2)
- G_LO(1)
- FCHAN95(2)
- G_LO(1)
- WVU(1)
- FCHAN95(2)
- G_LO(1)
- SWONG00(1)
- WVU(1)
- FCHAN95(3)
- G_LO(1)
- SWONG00(1)
- WVU(1)
- FCHAN95(4)
- G_LO(1)
- SWONG00(1)
- WVU(1)
- FCHAN95(5)
- G_LO(1)
- SWONG00(1)
- WVU(1)
- FCHAN95(6)
- G_LO(1)
- SWONG00(1)
- WVU(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement