这个 for 循环应该对树形图中包含的所有值求和。这可行,但在内循环之后,上下的值用于计算精度。似乎这永远不会执行。
我究竟做错了什么?
// for each row
for (Entry<String, TreeMap<String, Integer>> table_row : table.entrySet()) {
// write the label
String row = table_row.getKey() + ",";
int up = 0;
int down = 0;
float accu = 0;
// for each treemap in the row
for (Entry<String, Integer> collumn : table_row.getValue().entrySet()) {
row += collumn.getValue() + ",";
down += collumn.getValue();//this works
if (collumn.getKey() == table_row.getKey()) {
up = collumn.getValue();
}
}
---------> accu = (up / down) * 100; //this is not executed??
System.out.println("t: " + up + " n: " + down + " a: " + accu);
row = row + Float.toString(accu) + " %";
writer.println(row);//this works too but output is always 0%
}