Information Technology Reference
In-Depth Information
The compiler takes the type arguments and substitutes them for their corresponding type
parameters throughout the body of the generic class, producing the
constructed type—
from
which actual class instances are created.
Figure 19-4 shows the declaration of generic class
SomeClass
on the left. On the right, it
shows the constructed class created by using the type arguments
short
and
int
.
Figure 19-4.
Supplying type arguments for all the type parameters of a generic class produces a
constructed class from which actual class objects can be created.
Figure 19-5 illustrates the difference between
type parameters
and
type arguments
.
Generic class declarations have type parameters.
Type arguments are the actual types you supply when creating a constructed type.
Figure 19-5.
Type parameters versus type arguments