I have a List of objects.
eg>
Object 1
groupId=1 name=name1
Object 2
groupId=1 name=name2
Object 3
groupId=1 name=name3
Object 4
groupId=2 name=name4
Multiple objects in the List have same value for groupId. I need to create Sub-Lists of objects with same groupId. How do I do this in Java.
My Inital thought was to create a HashMap<Integer,List<Object>> but i am unsure about indefinite values of groupIds coming in , which in turn makes me unsure about  how to group objects with same groupIds together with groupId as the hashmap's key. 
If the groupId's were not to change or increase in the future i could have iterated over the original list and written a switch statement to create required arrays.