Section 20.8 Wildcards in Methods That Accept Type Parameters

• Class Number is the superclass of both Integer and Double.

Number method doubleValue (p. 862) obtains the Number’s underlying primitive value as a double value.

• Wildcard type arguments enable you to specify method parameters, return values, variables, and so on, that act as supertypes of parameterized types. A wildcard-type argument is denoted by ? (p. 862), which represents an “unknown type.” A wildcard can also have an upper bound.

• Because a wildcard (?) is not a type-parameter name, you cannot use it as a type name throughout a method’s body.

• If a wildcard is specified without an upper bound, then only the methods of type Object can be invoked on values of the wildcard ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.