Java language

Reifiable types

An unbounded wildcard parameterized type is reifiable; the runtime test does not identify a specific element argument.

Formal Syntax & Structure

java syntaxjava
value instanceof List<?> list

Working Example

Example Snippetjava
import java.util.*;public class Main {    static final class Box<T> {        private final T value;        Box(T value) { this.value = value; }        T get() { return value; }    }    public static void main(String[] args) {        Box<String> a = new Box<>("Map");        Box<Integer> b = new Box<>(3);        System.out.println(a.getClass() == b.getClass());        Object x = List.of("Map", "Atlas");        if (x instanceof List<?> list) {            System.out.println(list.size());            System.out.println(list.get(0) instanceof String);        }    }}
Java Reference