Summary

Section 18.1 Introduction

  • Generic methods enable programmers to specify, with a single method declaration, a set of related methods.

  • Generic classes enable programmers to specify, with a single class declaration, a set of related types.

  • Generic methods and classes are among Java’s most powerful capabilities for software reuse with compile-time type safety.

Section 18.2 Motivation for Generic Methods

  • Overloaded methods are often used to perform similar operations on different types of data.

  • When the compiler encounters a method call, it attempts to locate a method declaration that has the same method name and parameters that match the argument types in the method call.

Section 18.3 Generic Methods: Implementation and Compile-Time Translation ...

Get Java™ How to Program, Seventh 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.