Java language

Lower-bounded wildcard

Allows lists with an unknown element type that can accept Integer; reading yields Object without additional type checks.

Formal Syntax & Structure

java syntaxjava
List<? super Integer>

Working Example

Example Snippetjava
import java.util.*;public class Main {    static <T> void copy(List<? extends T> source, List<? super T> destination) {        for (T value : source) destination.add(value);    }    public static void main(String[] args) {        List<Integer> source = List.of(2, 4);        List<Number> target = new ArrayList<>();        copy(source, target);        System.out.println(target);        List<Object> other = new ArrayList<>();        copy(List.of("Map"), other);        System.out.println(other);    }}
Java Reference