Chapter 22

Ten Useful Classes in the Java API

IN THIS CHAPTER

check Finding out more about classes

check Discovering other helpful classes

I’m proud of myself. I’ve written around 400 pages about Java using fewer than 30 classes from the Java API. The standard API has thousands of classes, so I think I’m doing very well.

Anyway, to help acquaint you with some of my favorite Java API classes, this chapter contains a brief list. Some of the classes in this list appear in examples throughout this book. Others are so darn useful that I can’t finish the book without including them.

For more information on the classes in this chapter, check Java’s online API documentation at http://docs.oracle.com/javase/8/docs/api.

ArrayList

Chapter 16 introduces arrays. This is good stuff, but in any programming language, arrays have their limitations. For example, take an array of size 100. If you suddenly need to store a 101st value, you’re plain out of luck. You can’t change an array’s size without rewriting some code. Inserting a value into an array is another problem. To squeeze "Tim" alphabetically between "Thom" and "Tom", you may have to make room by moving thousands of "Tyler", "Uriah", and "Victor" names.

But Java has an ArrayList class. An ArrayList is like an array, except that ArrayList objects grow ...

Get Beginning Programming with Java For Dummies, 5th 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.