Map.getOrDefault(Object,Supplier<V>) override

John Rose john.r.rose at
Thu Apr 18 15:43:31 PDT 2013

On Apr 18, 2013, at 2:54 PM, Brian Goetz <brian.goetz at> wrote:

> Capturing stateless (non-capturing) lambdas is essentially free.

All the examples I gave are (intentionally) the stateless kind.

It seems to me that most times I've wanted getOrDefault I've had a specific constant sentinel value in mind.

All-time favorite:  My map is a histogram, and I want to turn those pesky nulls into Integer.valueOf(0) as quickly as possible.  The supplier-based version of that is the same cost as the T-value-based.

— John

More information about the lambda-dev mailing list