/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
        Map < String, Double > map1 =
                Map.of(
                        "X1" , 1d ,
                        "X2" , 1d
                );

        Map < String, Double > map2 =
                Map.of(
                        "X1" , 2d ,
                        "X2" , 2d ,
                        "X3" , 7d
                );

        Map < String, Double > map = new HashMap <>();
        Stream
                .concat( map1.entrySet().stream() , map2.entrySet().stream() )
                .forEach(
                        stringDoubleEntry ->
                                map.put(
                                        stringDoubleEntry.getKey() ,                                                                        // key
                                        map.getOrDefault( stringDoubleEntry.getKey() , 0d ) + stringDoubleEntry.getValue() )  // value
                );

        System.out.println( "map = " + map );
	}
}