Start of Tutorial > Start of Trail > Start of Lesson | Search |
When you define a new interface, you are in essence defining a new reference data type. You can use interface names anywhere you can use any other data type name.For example, the
AlarmClock
class uses theSleeper
type in two places:
- To declare an array of
Sleeper
s (shown in bold):private Sleeper[] sleepers = new Sleeper[MAX_CAPACITY];- As an argument to
letMeSleepFor
(shown in bold):private boolean letMeSleepFor(Sleeper theSleeper, int time) { . . . }
Start of Tutorial > Start of Trail > Start of Lesson | Search |