If there is an array or list that contains Foo objects, and I want to split the collection based on the property Foo.bar, is there a quick way to do it in Java besides using a map and traversing the collection?
For example, say the list looks like:
- Foo.bar = 1
- Foo.bar = 1
- Foo.bar = 2
- Foo.bar = 3
- Foo.bar = 3
- Foo.bar = 4
The list will be split into 4 different lists because there are 4 distinct values of bar.