 <p>Sometimes, A map can be used as a sort of switch. Eg:</p> <pre><code>Map&lt;Long, Runnable&gt; map = new HashMap&lt;Long, Runnable&gt;(); map.put(1L, new Runnable() { ... }); map.put(2L, new Runnable() { ... }); ... map.put(Long.MAX_VALUE, new Runnable() { ... }); map.get(someLongValue).run(); </code></pre>