fork download
  1. import java.math.BigDecimal;
  2. import java.util.HashMap;
  3. import java.util.TreeMap;
  4.  
  5. class Main {
  6. public static void main (String[] args) {
  7. BigDecimal foo = new BigDecimal("1.00");
  8. BigDecimal bar = new BigDecimal("1.000");
  9.  
  10. HashMap<BigDecimal, String> hash = new HashMap();
  11. TreeMap<BigDecimal, String> tree = new TreeMap();
  12.  
  13. hash.put(foo, "foo");
  14. hash.put(bar, "bar");
  15.  
  16. tree.put(foo, "foo");
  17. tree.put(bar, "bar");
  18.  
  19. System.out.println("hash foo: " + hash.get(foo));
  20. System.out.println("hash bar: " + hash.get(bar));
  21.  
  22. System.out.println("tree foo: " + tree.get(foo));
  23. System.out.println("tree bar: " + tree.get(bar));
  24. }
  25. }
Success #stdin #stdout 0.11s 320256KB
stdin
Standard input is empty
stdout
hash foo: foo
hash bar: bar
tree foo: bar
tree bar: bar