Why enter the parameter <K, V> needed to enter <K, V>?

In java.util.Map(as shown below) enter the parameters <K, V> Entryaccording to the parameters of the type of shadow copy <K, V> Map.

interface Map<K,V> {
      ......
      interface Entry<K,V> {
           .....
      }
}

class DblyLinkListof here has the following inner class DListNode, which does not require a shadow type parameter T.

public class DblyLinkList<T> implements Iterable<T> {
     .......
     class DListNode {
          private T item;
        private DListNode prev;
        private DListNode next;

        DListNode(T item, DListNode p, DListNode n) {
            this.item = item;
            this.prev = p;
            this.next = n;
        }
      }
      ......
}

Could you help me understand the reason for the shadowing of type parameters Map?

+4
source share
1 answer

, , , , . Entry K V .

, DListNode DblyLinkList<T> , , T - .

, DListNode static class ( ), - DListNode<K,V>.

+6

Source: https://habr.com/ru/post/1605667/


All Articles