O'Reilly logo

Java All-in-One For Dummies, 4th Edition by Doug Lowe

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3

Using the ArrayList Class

In This Chapter

arrow Working with the ArrayList class

arrow Creating an array list

arrow Introducing generics

arrow Adding elements to an array list

arrow Deleting elements from or modifying elements in an array list

Some people love to collect things: nick-knacks, baseball cards, postage stamps, dolls — you name it, someone collects it.

If I were a collector of some random thing — say, old tin advertising signs — an array would be a poor choice for storing the data. That's because on any given day, I may find another tin sign at a yard sale. So if I had 87 tin signs before, and I had created an array big enough to hold all 87 signs, I'd have to change the array declaration to hold 88 signs.

Java's collection classes are designed to simplify the programming for applications that have to keep track of groups of objects. These classes are very powerful and surprisingly easy to use — at least the basics, anyway. The more advanced features of collection classes take some serious ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required