Arrays are very essential, and it was also awhile before I fully grasped them. Take a look at this picture (but ignore the address part, that's not important for now):
This is a
1 dimensional array called
roll. Arrays can be named anything you'd like, but in this case, it's called roll. The Values row can be anything you define as well, but in this example they've already been defined for you.
If you look at the Name row you'll see it go roll[0], roll[1], roll[2], etc. See how it
starts at 0 and goes up by 1 for each column? The numbers inside those square brackets are called
indexes. Those are basically the ID's to access the values right below them. For example, the
index at 5 holds the number
49, the index at 0 holds 12, the index at 7 holds 11, and I'm sure by these examples you can determine what is stored at each index in the image.
Note: Most programming languages have their indexes
starting at 0, but some other languages start at a different number (e.g. Lua in Gmod starts at 1). Just be sure to google it to make sure (e.g. "starting index number for X programming language").
There's a lot you can do with arrays, one important concept you'll definitely come across in the future (if you continue with this) is seeing arrays stored inside of arrays. These are called
multidimensional arrays and can be even more confusing,
but, stick with trying to understand the 1 dimensional array as best as you can now and then when you do come across multidimensional arrays, they'll be a lot easier to understand.
Click to expand...