is the wildcard type
List>
.
Wildcards can be used to create restrictions on generic types. For example,
the upper bounded wildcard List extends Number> allows the
Number
type and all subclasses of Number. The lower bounded wildcard
List super Number>
allows the Number type and all superclasses
of Number.
Type Erasure
In order to preserve backwards compatibility, generic types are removed by the
compiler and replaced with object casts in a process called type erasure.
Type erasure prevents the need for legacy code to be recompiled, but it also
introduces several limitations. For example, generic exceptions are not allowed
because a catch block cannot tell the difference between
a GenericException and
a GenericException. Similarly, a class cannot implement
both Comparable and Comparable, because
without generic types they both represent the same interface.
Questions
What is the difference between a compile-time error and a runtime error?
What is the purpose of generics?
What are the different types of generic wildcards?
What is type erasure?
What are some of the limitations of generics?
Concurrency
Java supports concurrent programming through the use of threads. A thread
is a single path of execution in an application. The JVM typically launches
as a single process, spawning multiple threads that share its resources. Threads
that modify shared resources must be coordinated in order to prevent
unpredictable behavior.