Definition
An array is the most basic storage box in a computer's memory. It keeps data of the same type lined up in one row with no gaps. Each slot has a number tag (an index), so you can grab what's in any slot right away, without waiting, just by using its number.
How to Fill a Pill Organizer
Picture a pill organizer with compartments labeled Monday through Sunday. Each day's pills slip neatly into their own slot, and the slots sit snug against each other with no gaps in between.
Computers often build this kind of organizer to store data. That's exactly what an array is. When you create one, the computer sets aside rooms of the same size one after another in a continuous row of memory. Because the rooms sit side by side, the computer can keep track of the data very cleanly.
Here's the fun part: the number tags (indexes) on a computer's pill organizer usually start at 0. The first slot is room 0, and the second slot is room 1. In daily life we count from 1, but a computer thinks in terms of how far a slot is from the starting point, so the starting point itself is called 0.
The Trick to Jumping Straight to Any Slot
If your things are scattered all over the house, you have to search every room to find what you want. But what if you had a row of same-size drawers? If you know the drawer's number, you can open it with your eyes closed.
This fast lookup is an array's biggest strength. If the computer knows where the first room is and how big each room is, it can work out the address of any room with simple multiplication. For example, to find room 5 (the sixth slot, since counting starts at 0), it takes the starting address and adds "room size times 5" in one jump.
Thanks to this, finding the slot you want takes the same amount of time whether there are 10 items or a million. In computer science, this is called "random access": you go straight to the slot instead of searching in order.
To Be a Bit More Precise: Squeezing Things in the Middle Is Hard
But arrays have a clear weakness too. Say a full pill organizer needs one more pill squeezed in between Wednesday and Thursday. What do you do? You have to slide every pill from Thursday through Sunday one slot to the right before a gap opens up.
It's the same with arrays. To add new data at the front or in the middle, you have to move all the data behind it back one spot at a time. And if you delete something in the middle, you have to pull all the data behind it forward to fill the hole. That's why inserting or deleting data can be slow.
Another limit is that it's hard to grow or shrink the number of rooms you first made. When the box is full, you have to build a bigger new box and move all the old data into it. So for jobs where the size changes often or lots of data goes in the middle, people sometimes use other storage methods (such as linked lists) instead.
Common misconceptions
The first slot of an array is obviously number 1.
In most programming languages, the first slot's number (index) is 0. That's because the address is calculated from how far a slot is from the starting point (the distance).
Where you meet it
A music playlist on your smartphone is like this: the songs are lined up in order.
Writing student names in a class roll book from number 1 to number 30, in number order, works the same way.
In one sentence
An array lines data up in memory with no gaps so you can jump straight to any item by its number tag. It's the most basic data structure.