Chapter Table of Contents
Ch. 9 ArraysSection Table of Contents
Chapter Table of ContentsSection Table of ContentsWhat are arrays? Why do we use them?Arrays DiagramNext Section
What are arrays? Why do we use them?
When you want to organize a large set of data, arrays are really helpful. They are a powerful tool for structuring data and pop up in almost every coding language. Arrays can be one-dimensional (1D) or multi-dimensional (usually we only go up to 2D arrays). Arrays can store primitives and non-primitives. So let’s start playing with them!
Arrays Diagram
Just as with strings the indices of arrays start at zero. Thus if you tell the compiler to return you the length of the array below (using
nameOfArray.length
), it will return 10, but the indices (for example in your for loop which you will use to iterate through the array) will only go up till 9.Next Section
9.2 Declaring and Initializing ArraysCopyright © 2021 Code 4 Tomorrow. All rights reserved.
The code in this course is licensed under the MIT License.
If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.