Advertisement
alexandrecoussy

Untitled

Feb 15th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. Map<String, BigDecimal> map = new HashMap<String, BigDecimal>();
  2.         Function<String,BigDecimal> compute = key -> BigDecimal.TEN;  
  3.         map.put("1",BigDecimal.ONE);
  4.         map.computeIfAbsent("1", compute);
  5.         map.computeIfAbsent("2", compute);
  6.         System.out.println(map);
  7.        
  8.         map.clear();
  9.         map.put("1",null);
  10.         map.computeIfAbsent("1", compute);
  11.         map.computeIfAbsent("2", compute);
  12.         System.out.println(map);
  13.        
  14.         map.clear();
  15.         Function<String,BigDecimal> computeNul = key -> null;
  16.         map.computeIfAbsent("1", computeNul);
  17.         System.out.println(map);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement