Class AbstractMap.MapEntry<K,V>

java.lang.Object
com.zybooks.dsaj.map.AbstractMap.MapEntry<K,V>
Type Parameters:
K - The key type (keys must be unique)
V - The value type
All Implemented Interfaces:
Entry<K,V>
Enclosing class:
AbstractMap<K,V>

protected static class AbstractMap.MapEntry<K,V> extends Object implements Entry<K,V>
A concrete implementation of the Entry interface to be used within a Map implementation.
  • Constructor Details

    • MapEntry

      public MapEntry(K key, V value)
      Creates a new entry
      Parameters:
      key - the key to be stored
      value - the associate value to be stored
  • Method Details

    • getKey

      public K getKey()
      Returns the entry's key
      Specified by:
      getKey in interface Entry<K,V>
      Returns:
      the entry's key
    • getValue

      public V getValue()
      Returns the entry's value
      Specified by:
      getValue in interface Entry<K,V>
      Returns:
      the entry's value
    • setKey

      protected void setKey(K key)
      Sets the entry's key
      Parameters:
      key - the new key
    • setValue

      protected V setValue(V value)
      Sets the entry's value
      Parameters:
      value - the new value
      Returns:
      the old value
    • toString

      public String toString()
      Returns string representation (for debugging only)
      Overrides:
      toString in class Object
      Returns:
      string representation (for debugging only)