In most of this book, we’ve kept all our data either in properties of components or in global variables. These work great, but they have a limitation: They can’t expand. Sometimes we don’t know how much information we will need to store, and that’s another great use for lists.
The one-dimensional list we discussed earlier in this chapter is perfect for when we need our information to grow. With just one list, we can store any number of items in it.
Consider the contacts app we started imagining in the last section. The user might have 5 friends, or 50, or 500; our app should be able to handle all of them with no problem.
Clearly, we can’t make a global variable for each contact. We can’t guess how many friends the ...