How big is your locker?
Some Collections, like Built-in Arrays, have a set size. You need to tell Unity how many things you're putting inside, and that number can never change. Other Collections, like Generic Lists, can take whatever we throw at them—their length is elastic, and they don't have to have a set size. Which approach is better? As you'll see, there are advantages and disadvantages to each.
You'll remember that when we define a variable (a bucket that can hold one thing), we're actually carving out a storage locker in the computer's memory. By typing the variable (giving it a type), we're telling the computer how big that storage locker needs to be. An int
variable needs a different amount of room in memory than a string
variable or a boolean
variable, and so on.
It's the same idea with a Collection. If we tell Unity how many elements an array needs to hold, Unity can reserve the right amount of space in memory and call it a day. Imagine if you were moving house, and you had to...