Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Map<String, BigDecimal> map = new HashMap<String, BigDecimal>();
- Function<String,BigDecimal> compute = key -> BigDecimal.TEN;
- map.put("1",BigDecimal.ONE);
- map.computeIfAbsent("1", compute);
- map.computeIfAbsent("2", compute);
- System.out.println(map);
- map.clear();
- map.put("1",null);
- map.computeIfAbsent("1", compute);
- map.computeIfAbsent("2", compute);
- System.out.println(map);
- map.clear();
- Function<String,BigDecimal> computeNul = key -> null;
- map.computeIfAbsent("1", computeNul);
- System.out.println(map);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement