I'm very new to Java and I am trying to group by objects based on the number but I'm unable to make it. Here is the example:
SomeCollection<Integer,String> t=new SomeCollection<Integer,String>();
t.put("1","a");
t.put("1","b");
t.put("2","c");
output:
1 - a,b
2 - c
Basically, when numbers are same then value needs to be grouped under that same number. It's all about asking how to perform this kind of strategical output to achieve by using any collections. Any help is appreciated.
SomeCollectiona<Integer, List<String>>instead, and add the values to the list.TreeMap<Integer,List<String>>is a sensible idea!