Fiveable
Fiveable

Zero-based indexing

Definition

Zero-based indexing is a numbering system where the first element in an array or list is assigned index 0 instead of 1. This means that elements are accessed by their position relative to zero.

Analogy

Imagine you have lined up your favorite snacks on a table, starting from the left. The first snack would be at position 0, not position 1, because we start counting from zero.

Related terms

Array: A data structure that stores multiple values of the same type in contiguous memory locations.

Index Out Of Bounds Exception: An error that occurs when trying to access an element outside the valid range of indices in an array or list.

Length/Size Property: A property associated with arrays or lists that returns the number of elements they contain.

"Zero-based indexing" appears in:



© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.