I'm studying with Hashmap with Multiple parameters(1 key, 2 values) and i was able to find apache multiValueMap for my issue.
Here is my codes for multiValueMap.
import java.util.Set;
import org.apache.commons.collections.map.MultiValueMap;
import org.apache.commons.collections.MultiMap;
public class multiValueMap {
public static void main(String args[]) {
String a, b, c;
MultiMap mMap = new MultiValueMap();
mMap.put("a", "Hello there, It's a wonderful day");
mMap.put("a", "nice to meet you");
Set<String> keys = mMap.keySet();
for (String key : keys) {
System.out.println("Key = " + key);
System.out.println("Values = " + mMap.get(key));
a = String.valueOf(mMap.get(key));
System.out.println("A : " + a);
}
}
}
// The result as below
Key = a
Value = [Hello there, It's a wonderful day, nice to meet you]
A : [Hello there, It's a wonderful day, nice to meet you]
Here is my question how can I store first value for string b, and second for c? if I substring the MultiMap values depends on "," then it would stores Hello there only. please give me helpful your advices.
MultiValueMap
does under the hood