Hellow everyone,
I have a populated LinkedHashMap, and I need to insert another key/value to it, but it appears that it replaces it. How can I append it?
Here's the example:
Map <String, String>invalid = new LinkedHashMap<String, String>();
invalid.put("111111111111111111111", "Invalid Message # 1");
Map <String, String>valid = new LinkedHashMap<String, String>();
valid.put("222222222222222222222", "Valid Message # 2");
Map <String, String>invalid3 = new LinkedHashMap<String, String>();
invalid.put("33333333333333333333", "Invalid Message # 3");
Map <String, Map<String, String>>results = new LinkedHashMap<String, Map<String, String>>();
results.put("valid", valid);
results.put("invalid", invalid);
...
// Do some other stuff...
// now update the invalid Map, but the following appears to replace my existing "invalid" Map
results.get("invalid").putAll(invalid3);
System.out.println("size=" + results.size());
//================ RESULT ================
size=2
It should have 3 entries.
Can someone please let me know how can I add an entry to my "invalid" Map into my LinkedHashMap? Thanks.