Reputation: 5526
This is what I am trying to do :
Having a list of channel names where each channel name has several members. Both are Strings.
What I am doing now is having a 2d ArrayList.First value on each ArrayList is the channel name and next are its members. Is there a better way to do this (without creating classes) ?
Can a Map have many values for one key ? So that I have a channel as Key and members as Values to that Key ?
Thanks !
Upvotes: 1
Views: 991
Reputation: 121820
Yes, a Java Map
can have any types of keys or values.
What you probably want here is a Map<String, Set<String>>
(since I assume a channel cannot have the same member twice, right?).
And any really means any: you may even have Map
s as keys to Map
s.
Upvotes: 3