title: Java how to create a custom Exception to limit the size of a HashMap
body: <p>I have a method which inserts new items to a <code>HashMap</code>, I want to limit the size of the <code>HashMap</code> by throw an <code>exception</code> when the size of the HashMap is larger than a specific value, say <code>100</code>, below is my implementation:</p>
  
  <pre><code>public void addToHashMap(String id, Object value) throws HashMapOutOfBoundException{
      hashMap.put(id,value);    
  }
  
  private class HashMapOutOfBoundException extends Exception{
      //what should I do inside this class?
  }
  </code></pre>