Chapter 6. Using the Java Library: Get to Know the Java API
Java ships with hundreds of prebuilt 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 prebuilt 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.
In our last chapter, we left you with the cliff-hanger: a bug
How itâs supposed to look
Hereâs what happens when we run it and enter the numbers 1,2,3,4,5,6. Lookinâ good.
A complete game interaction (your mileage may vary)
How the bug looks
Hereâs what happens when we enter 2,2,2.
A different game interaction (yikes)
In the current version, ...
Get Head First Java, 3rd 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.