I'm new to working with Java threads, so I apologize for any misunderstandings.
I want to use Collect on my stream to return a stream that has grouped strings that correspond to all elements, but one to the singular string into which this one element is added to the set.
For example, if my stream contains data:
[{12, "Apple", "Gala"},
{12, "Apple", "Fuji"},
{13, "Orange", "Navel"},
{13, "Orange", "Valencia"}]
After collecting for column 3, it will return a stream with data:
[{12, "Apple", ["Gala", "Fuji"]},
{13, "Orange", ["Navel", "Valencia"]}]
Is this possible with a stream collection method? Any help is much appreciated!
Thank.
source
share