New methods in java.util.Map
Chris Bouchard
chris at upliftinglemma.net
Thu Oct 16 19:14:46 UTC 2025
Alberto,
I believe your getOrPut methods already exist as putIfAbsent and
computeIfAbsent, unless I'm missing a subtle difference.
On Thu, Oct 16, 2025, 14:20 Alberto Otero Rodríguez <alber84ou at gmail.com>
wrote:
> Also, other two new methods might be interesting if you want to get a
> value from a map, but if the key doesn't exist you want to insert that
> value in the map and return it:
>
> default V getOrPut(Object key, V defaultValue)
>
> default V getOrPut(Object key, Function<? super K, ? extends V>
> defaultValueFunction)
>
Chris
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20251016/caa75ed0/attachment-0001.htm>
More information about the amber-dev
mailing list