Using compute() Method.
- compute() - Computes a new value using the specified function. It then associates the computed value to the specified key.
- computeIfAbsent() - If the specified key is not mapped to any value, the method will compute a new value using the
specified function. It then associates the new value with the key.
- computeIfPresent() - If the specified key is already mapped to any value, this method will compute a new value using the specified function. It then associates the new value with the key.
Output