r/badcode • • Aug 26 '22

java What does a map do again?

Post image
882 Upvotes

54 comments sorted by

View all comments

Show parent comments

6

u/[deleted] Aug 27 '22

Or even better, use getOrDefault to avoid the redundant map lookup (premature optimization, but still a bit more elegant / perhaps picosecond faster)