Lesson 13Organizing with Arrays
Arrays are the first collection type that we are going to learn about. It is the most fundamental of the collection types, and many of the other collection types we will learn later use the array structure under the covers in creative ways to yield interesting effects.
When we mention that a type is a collection, we mean that it can hold multiple simple or complex data values inside it.
WHAT IS AN ARRAY?
We have covered a lot of Java basics up to this point. We understand variable types, and we can use flow of control statements to branch and loop our code blocks. We also learned how to group repeatable blocks of code into methods. The next piece we need to understand is how to store and work with collections of items.
Consider a situation where we want to store a list of five integers. Without collections like arrays, we would have to declare five variables. That's maybe not a big deal when we are talking about five variables, but what if you had to store 10,000 variables? This is where arrays help us.
An array is a set of uniform data elements that can ...
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