hash

A collection of 1 posts

A Java geek
  • Me
  • Books
  • Speaking
  • Mentions
  • Focus
Aug 11, 2024 hashmap dict hash

Default map value

In this post, I’ll explain how to provide a default value when querying an absent key in a hash map in different programming languages. Java Let’s start with Java, my first professional programming language. In older versions, retrieving a value from a map required using the get() method: Map map = new HashMap(); (1) Object value = map.get(new Object()); (2) if (value == null) { value = 'default';

Nicolas Fränkel
A Java geek © 2008-2025
v. b03b447fbe7feebf87852349bcccf3d237a72536/10180576914
Latest Posts