I have an Userdefined Object which contains multiple properties. As they all have same datatype as String, I wanted to use Streams to collect all those properties values into a Map. I am not aware that Collectors.toMap() or Collectors.groupingBy() is able to serve this.
public class TeamMates{
private String playerFirstName;
private String playerLastName;
private String playerMaidenName;
//Constructors , getters and Setters
}
I have an List<TeamMates> object which I wanted to use it to stream and collect it into a Map<String,List<String>>.
I wanted the Map to contain
(playerFirstName,("John","Bob"));
(playerLastName,("Joe","Henry"));
(playerMaidenName,("H","K"));
As I don't wanted to use streaming multiple times to collect each property individually or using forEach, is there any way to get the above properties with a single stream.