Currently the code below will give me a line by line listing of the values, if i wanted to sum the values for one total, can someone give me an example of going about doing this?
if (value != null && !value.isEmpty()) {
Set set = value.keySet();
Object[] key = set.toArray();
Arrays.sort(key);
// System.out.println("test" + Arrays.asList(key));
for (int i = 0; i < key.length; i++) {
// System.out.println(value.get((String)key[i]))
ArrayList list = (ArrayList) value.get((String) key[i]);
if (list != null && !list.isEmpty()) {
Iterator iter = list.iterator();
double itemValue = 0;
while (iter.hasNext()) {
Iemunbuf p = (Itemunbuf) iter.next();
if (p != null) {
propertyValue = itemValue + p.getitemValue().doubleValue();
System.out.println(itemValue);
}
// buf2.append(NL);
buf2.append(t1 + "\t");
// System.out.println(t1);
buf2.append(NL);
}
buf1.append(NL);
double amount = itemValue;
buf1.append(" " + money.format(amount) + " ");
}
}
}
Don’t know why you assign a value to amount just to print it – I suspect that what you mean to do was use amount as a grand total. Well it won’t work the way you have written as amount is declared inside your loop and so will always be initialized to 0.0 before you make the assignment – that and it is a flat out assignment and not summation. Declare amount outside the loop like Erick suggested then say amount += itemValue.
Hope I understood your question properly.