Array is some kind of data structures that act as a collections of related data items or we can imagine it as a bag that store a bunch of data of same data type.
For example, if you are trying to process a series of number in same category, so you need a variable to store all of this together, so the best way to complete it is using Array.

If i need 5 number to do some processing, so i declare it into an array. But there ae 2 ways to declare a new arrays, either it is declare it with a specific size of array or initialize it when declare it.

** Be aware that the first index of the array always start with 0.
** and be aware that do not try to access the element with index out of the size assigned, it will trigger index out of bound exception.

// format is dataType[] variableName = new dataType[size]
int[] processedNum = new int[5];
processedNum[0] = 1;
processedNum[1] = 5;
processedNum[2] = 2;
processedNum[3] = 7;
processedNum[4] = 9;

or,

//this will directly assign the value to the array
int[] processedNum = {1,5,2,7,9};

more example,

String[] stringArray = {"firstString", "secondString", "thirdString"};

Below is a example to declare and do some processing by using the array,



below is an example when access out of the maximum element in the array,