Section 20.3 Generic Methods: Implementation and Compile-Time Translation

• If the operations performed by several overloaded methods are identical for each argument type, they can be more compactly and conveniently coded using a generic method. A single generic method declaration can be called with arguments of different data types. Based on the types of the arguments passed to a generic method, the compiler handles each method call appropriately.

• All generic method declarations have a type-parameter section (p. 843) delimited by angle brackets (< and >) that precedes the method’s return type (p. 843).

• A type-parameter section contains one or more type parameters separated by commas.

• A type parameter (p. 843) is an identifier that specifies ...

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.