I am trying to create a single map from list of maps. Which contains only key "1" and all the values of key "1" across different maps under that list using Java 8 stream API.
List<Map<String,Object>> list=new ArrayList<>();
Map<String,Object> map1=new HashMap<>();
map1.put("1", Arrays.asList(new String[] {"A"}));
map1.put("2", Arrays.asList(new String[] {"B"}));
Map<String,Object> map2=new HashMap<>();
map2.put("1", Arrays.asList(new String[] {"C"}));
map2.put("2", Arrays.asList(new String[] {"D"}));
Required output :- {1=[A, C]}
listasList<Map<String,List<Object>>>? Otherwise why isn't{1=[[A], [C]]}the expected output?List<Map<String,List<Strinig>>>as input type, the very first question you should ask yourself is why do you need such a complex representation of data, is there no way tto simplify it?