IN THIS CHAPTER
Working with the ArrayList class
Creating an array list
Adding elements to an array list
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 ...