Chapter 5: Programming to an Interface
5.1 Introduction
This chapter introduces the concept of a Java interface. An interface in Java is a definition of behavior to be implemented by objects. Once an interface is defined, components can then be written to take advantage of the behavior promised in the interface. These components can then be reused, as they work with any object that implements the behavior of the interface. This is a type of reuse that we will call generic reuse.* Note that an interface is not a data type, which is a collection of data values and operations on those values. An interface is simply a definition of behavior an object must implement to work correctly with an algorithm, collection class, or component. However, like ...
Get Creating Components 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.