Class MapEntry<K,​V>

  • Type Parameters:
    K - the type of the key of this entry.
    V - the type of the value of this entry.
    All Implemented Interfaces:
    Map.Entry<K,​V>

    public class MapEntry<K,​V>
    extends Object
    implements Map.Entry<K,​V>
    Understands an entry in a Map.
    Author:
    Yvonne Wang
    • Field Detail

      • key

        public final K key
      • value

        public final V value
    • Method Detail

      • entry

        public static <K,​V> MapEntry<K,​V> entry​(K key,
                                                            V value)
        Creates a new MapEntry.
        Type Parameters:
        K - the type of the key of this entry.
        V - the type of the value of this entry.
        Parameters:
        key - the key of the entry to create.
        value - the value of the entry to create.
        Returns:
        the created MapEntry.
      • setValue

        public V setValue​(V value)
        Always throws UnsupportedOperationException, as this class represents an immutable map entry.
        Specified by:
        setValue in interface Map.Entry<K,​V>
        Parameters:
        value - ignored
        Returns:
        (Does not return)
        Throws:
        UnsupportedOperationException - always