Assigning Values to Arrays

Assigning Values

After being created/declared, access and element or “slot” of the array variable by its index.

Picture an array like a numbered list starting at zero...

shoppingList

0

"milk"

1

"bread"

2

"eggs"

3

"bottled water"

4

"soda"

ages

0

12

1

31

2

7

3

80

4

45

5

50

6

51

7

50

Example Code:

Processing:

Equivalent to:

Last updated

Was this helpful?