I have a list of comma separated strings -
List: format = <unique id, label>
----- values -----
ab123,X
cd123,Y
ab123,Y
cd123,Z
------------------
I want to convert this list to Map<String, List<String>>
using java 8 where key would be the unique id and value would be the list of labels (Map<unique-id, List<label>>).
Example -
Map[
ab123=List[X, Y],
cd123=List[Y, Z]
]
Could you please help me here so that I could implement this using java 8.
Also instead of Map, if I want to use dto class -
Class A {
private String id;
private List<String> labelList;
// Getters and Setters methods
}
and I expect to create a list of class A
, for example -
List[
A [id="ab123", labelList = List[X, Y],
A [id="cd123", labelList = List[Y, Z]
]
How could I get that?