Use a Java Array
While variables with individual values are useful and common, sometimes you need more than that. You need to keep track of all the players in the system, or one player’s inventory items, or a to-do list, or a grocery list, or a homework list.
Java has you covered. There are several different ways to keep and access piles of data. We’re going to focus on a few: the simple Array, the classier ArrayList, and the remarkably handy if somewhat alien HashMap (covered in the next chapter). First up, the Array.
There are actually a few different Array-like collections in Java, including Array, Vector, LinkedList, and ArrayList types. They each work differently on the inside, are stored slightly differently, and perform differently ...
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