Вам необходимо назначить новый HashMap
экземпляр для valueFromEachOfThoseNineFields
каждый раз, когда вы хотите сохранить значения в нем, а затем сохранить valueFromEachOfThoseNineFields
в fileNameConstrains
следующим образом:
import java.util.HashMap;
public class Main {
public static void main(String[] args) {
System.out.println(getDataDictionary());
}
public static HashMap<String, HashMap<String, Object>> getDataDictionary() {
// Virtual Data Creation - Simulating The 9 Fields HAR value
HashMap<String, Object> valueFromEachOfThoseNineFields;
HashMap<String, HashMap<String, Object>> fileNameConstrains = new HashMap<String, HashMap<String, Object>>();
valueFromEachOfThoseNineFields = new HashMap<String, Object>();
valueFromEachOfThoseNineFields.put("A", 10);
valueFromEachOfThoseNineFields.put("B", 20);
valueFromEachOfThoseNineFields.put("C", 30);
valueFromEachOfThoseNineFields.put("D", 10);
valueFromEachOfThoseNineFields.put("E", 5);
valueFromEachOfThoseNineFields.put("F", 20);
valueFromEachOfThoseNineFields.put("G", 1);
valueFromEachOfThoseNineFields.put("H", 100);
valueFromEachOfThoseNineFields.put("I", 66);
fileNameConstrains.put("File1", valueFromEachOfThoseNineFields);
valueFromEachOfThoseNineFields = new HashMap<String, Object>();
valueFromEachOfThoseNineFields.put("A", 10);
valueFromEachOfThoseNineFields.put("B", 50);
valueFromEachOfThoseNineFields.put("C", 30);
valueFromEachOfThoseNineFields.put("D", 90);
valueFromEachOfThoseNineFields.put("E", 5);
valueFromEachOfThoseNineFields.put("F", 20);
valueFromEachOfThoseNineFields.put("G", 10);
valueFromEachOfThoseNineFields.put("H", 90);
valueFromEachOfThoseNineFields.put("I", 61);
fileNameConstrains.put("File2", valueFromEachOfThoseNineFields);
valueFromEachOfThoseNineFields = new HashMap<String, Object>();
valueFromEachOfThoseNineFields.put("A", 10);
valueFromEachOfThoseNineFields.put("B", 60);
valueFromEachOfThoseNineFields.put("C", 30);
valueFromEachOfThoseNineFields.put("D", 2);
valueFromEachOfThoseNineFields.put("E", 13);
valueFromEachOfThoseNineFields.put("F", 9);
valueFromEachOfThoseNineFields.put("G", 15);
valueFromEachOfThoseNineFields.put("H", 88);
valueFromEachOfThoseNineFields.put("I", 69);
fileNameConstrains.put("File3", valueFromEachOfThoseNineFields);
return fileNameConstrains;
}
}
Вывод:
{File3={A=10, B=60, C=30, D=2, E=13, F=9, G=15, H=88, I=69}, File2={A=10, B=50, C=30, D=90, E=5, F=20, G=10, H=90, I=61}, File1={A=10, B=20, C=30, D=10, E=5, F=20, G=1, H=100, I=66}}