Skip to content

Instantly share code, notes, and snippets.

@raymcdermott
Created February 12, 2011 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raymcdermott/823982 to your computer and use it in GitHub Desktop.
Save raymcdermott/823982 to your computer and use it in GitHub Desktop.
For loop over map in Java 1.6
private Map<CartItem, Integer> cart = new HashMap<CartItem, Integer>();
public Double getTotalItemFees() {
Double fees = 0.0;
for (Map.Entry<CartItem, Integer> entry : cart.entrySet()) {
Integer quantity = entry.getValue();
CartItem cartItem = entry.getKey();
fees += (quantity * cartItem.getFee())
}
return fees;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment