warehouse car[2]; means that there are two elements in array: first one is car[0] and the second one is car[1]. warehouse car[1]; is an array with only one element in it, so when you try to access nonexistent second element, debugger gives you an error, since that could harm your whole program.