Let's say we need to store 10 numbers. We could store the numbers in 10 variables like such:
Scanner scan = new Scanner(System.in); int a,b,c,d,e,f,g,h,i,j; scan.nextInt(a); scan.nextInt(b); scan.nextInt(c); scan.nextInt(d); scan.nextInt(e); scan.nextInt(f); scan.nextInt(g); scan.nextInt(h); scan.nextInt(i); scan.nextInt(j);
However, if we had to store 100 numbers, this process would be very tedious and annoying. A better way would be to use a block of numbers and treat it as one variable instead of many variables. This is called an array.
An array is the most basic data structure that stores elements of the same type in a fixed block. The fact that it is in one block and the same type is important because it allows accessing elements very quickly if you have the index. All you have to do is look at the index and retrieve the element. However, inserting elements in the array is slow because you would have to shift all the elements and also if you want to shift past the fixed size you will get an error. (Imagine the parking spaces are full and you wanted to insert a car somewhere, there will still be one car that will have no parking space).
Arrays can be multidimensional meaning you can have an array of array of objects. (Imagine a parking lot with multiple rows of parking spaces).