PrepZone Logo
PrepZone
Back to Java

Java · Hard

Explain bounded wildcards in generics: <? extends T> vs <? super T>. What is the PECS principle?

JavaCore Java

Answer preview

? extends T (upper bounded): The wildcard represents T or any subtype of T. You can read from this structure (elements are at least T) but cannot safely write to it (you don't know the exact subtype).…