20. Generic Classes and Methods

...our special individuality, as distinguished from our generic humanity.

—Oliver Wendell Holmes, Sr.

Born under one law, to another bound.

—Lord Brooke

Objectives

In this chapter you’ll:

Image Create generic methods that perform identical tasks on arguments of different types.

Image Create a generic Stack class that can be used to store objects of any class or interface type.

Image Undestand compile-time translation of generic methods ...

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.