Today we'll get more practice working with interfaces.
We'll move past our friend
Comparable and look at two new interfaces that allow us to integrate with a built-in language feature—the
for in loop.
Let's have more fun with interfaces.
Remember our good old
So it turns out that we can implement our own classes that can be used in the
Let's look at the interfaces that are required and consider how they work.
We'll examine them both at once, since they are really designed to work together:
Now let's put what we know to use to build a simple random number generator.
We'll create a class that can be used on the right side of a
for loop and generates a certain number of random
Next, let's look at a few improvements to our iterable random number generator based on what we've already done.