Java ships with hundreds of pre-built classes. You don’t have to reinvent the wheel if you know how to find what you need in the Java library, known as the Java API. You’ve got better things to do. If you’re going to write code, you might as well write only the parts that are truly custom for your application. You know those programmers who walk out the door each night at 5 PM? The ones who don’t even show up until 10 AM? They use the Java API. And about eight pages from now, so will you. The core Java library is a giant pile of classes just waiting for you to use like building blocks, to assemble your own program out of largely pre-built code. The Ready-bake Java we use in this book is code you don’t have to create from scratch, but you still have to type it. The Java API is full of code you don’t even have to type. All you need to do is learn to use it.
Here’s what happens when we run it and enter the numbers 1,2,3,4,5,6. Lookin’ good.
(your mileage may vary)
Here’s what happens when we enter 2,2,2.
In the current version, once you get a hit, you can simply repeat ...