表Guava和HashMap

时间:2017-04-27 09:35:30

标签: java hashmap guava

我有Table<String,String,Doube>HashMap<String,Double>employeeYearsOfService

 AT&T={Bill Smith=2.0, Stacy Lerner=1.4},
 fatima={Bill Smith=1.0, Stacy Lerner=3.0}

HashMap hm1

AT&T=0.962, 
fatima=0.888

我想计算一下并将结果存入新的HashMap hm4

calcul是

for column BIll Smith| 2.0*0.962+.0888*1.0=2.812


for column Stacy Lenner|1.4*0.962+3.0*0.888=4.0108

结果我的新HashMap hm4

AT&T=0.2.812
fatima=4.0108

我的代码

我为我的HashMap和Table使用循环,但结果是错误的

     Double res = 0.0;
       for (Double mapValue : hm1.values()) {
            for (String ke : employeeYearsOfService.columnKeySet()) {

              for (Entry<String, Double> employeek : 
              employeeYearsOfService.column(ke).entrySet()) {


                res+ = employeek.getValue() * mapValue.doubleValue();

           }

            hm4.put(ke, res);
        }
    }

你能帮我找到我的错误吗?

0 个答案:

没有答案