Wildcard Parameterized Types

This section describes wildcard parameterized types where a argument type contains the wildcard character '?' and represents a group of types instead of a single type.

What Is a Wildcard Parameterized Type? A wildcard parameterized type is a parameterized type of a generic class or interface, where the argument type represents a group of types, instead of a single type.

The objective of using a wildcard parameterized type is to create a new parameterized type that is wider than a normal parameterized type, so that you can use it a supertype of the normal parameterized type. Here is some examples of wildcard parameterized type:

   java.util.List<?> a;
   java.util.List<? extends Number> b;
   java.util.List<? extends Integer> c;
   java.util.List<? super Integer> d;

Wildcard parameterized types can be divided into 3 groups:

The diagram below shows you some examples of supertype-subtype relationships of wildcard parameterized types and parameterized types:
Java Wildcard Parameterized Type Subtyping

Last update: 2014.

Table of Contents

 About This Book

 Installing JDK 1.8 on Windows

 Execution Process, Entry Point, Input and Output

 Primitive Data Types and Literals

 Bits, Bytes, Bitwise and Shift Operations

 Managing Bit Strings in Byte Arrays

 Reference Data Types and Variables

 StringBuffer - The String Buffer Class

 System Properties and Runtime Object Methods

Generic Classes and Parameterized Types

 What Is a Generic Class?

 Using a Generic Class

 Using a Generic Class - Example

 Creating a Generic Class

 Creating a Generic Class - Example

 Bounded Type Parameters

 Raw Type, Generic Type and Parameterized Type

 Parameterized Type and Subtyping

Wildcard Parameterized Types

 Wildcard Parameterized Type Test

 Wildcard Parameterized Subtyping

 Wildcard Parameterized Subtyping Example

 Generic Methods and Type Inference

 Lambda Expressions and Method References

 Execution Threads and Multi-Threading Java Programs

 ThreadGroup Class and "system" ThreadGroup Tree

 Synchronization Technique and Synchronized Code Blocks

 Deadlock Condition Example Programs

 Garbage Collection and the gc() Method

 Outdated Tutorials


 PDF Printing Version