Chapter 21
Ten Useful Classes in the Java API
IN THIS CHAPTER
Finding out more about classes
Discovering other helpful classes
I’m proud of myself. I’ve written around 400 pages in this book 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 https://docs.oracle.com/en/java/javase/17/docs/api.
ArrayList
How often do you deal with many things at once? You have many customers, many contacts, many bills to pay, many social media posts — many, many, many! Each Java collection class has its own, special characteristics. A Queue stores things as they wait to take their turn. A Stack ignores older things in favor of more recent things. A Set has no ordering. A Map connects names with their values.
My go-to collection class is the ArrayList. An ArrayList is like an array, except that ArrayList objects grow and shrink as needed. You can also insert new values ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access