title: Why is there a nested class in this implementation of the HashTable ADT (code from a textbook)?
body: <p>I was reading my textbook and stumbled onto this piece of code: </p>
  
  <pre><code> public abstract class AbstractMap&lt;K,V&gt; implements Map&lt;K,V&gt; {
      public boolean isEmpty() { return size() == 0; } 
            //---------------- nested MapEntry class ---------------
                protected static class MapEntry&lt;K,V&gt; implements Entry&lt;K,V&gt; { 
                   private K k; // key 
                    private V v; // value 
                   public MapEntry(K key, V value) { 
                      k = key; 
                      v = value; 
                    } 
                   // public methods of the Entry interface 
                    public K getKey() { return k; } 
                    public V getValue() { return v; } 
                  // utilities not exposed as part of the Entry interface                    
                      protected void setKey(K key) { k = key; }  
                      protected V setValue(V value) { 
                       V old = v; 
                       v = value; 
                       return old; 
                      } 
                 } 
           //----------- end of nested MapEntry class ----------
  </code></pre>
  
  <p>I've been trying to figure this out for a while. I just can't seem to realize why is that nested class so important. Wouldn't be possible to just omit that nested class and just put all those methods in the AbstractMap class? Is it for security purposes ( like linked lists and Nodes?)</p>
  
  <p>Feel free to tell me if this isn't the right place to post this question as the code isn't mine, but one from my textbook.</p>