Relative Content

Tag Archive for javagenericscompiler-errorswildcard

The difference between Java wildcards “ and “

class Pair<T, E> { private final T first; private final E last; Pair(T first, E last) { this.first = first; this.last = last; } } This is a regular multi-type generic class. Pair<String, Integer>[] arrayPair = new Pair<?,?>[10]; // error, need cast Pair<String, Integer>[] arrayPair = new Pair<?>[10]; // pass But for generic classes with […]