Arrays are groups of same Type variables that are accessed by their index. Once an array is cerated, the dimension of it cannot be changed, so, always take that in mind when using arrays or you will have an error.


There are different way to declare an array

int array1[] = new int[10];

int[] array2 = new int[10];

One Dimensional Arrays

This is a list of variable of the same type. First , declare a variable of a certain type, than you must allocate the memory to hold the array with the keyword new. You can access an element of the array with its index like this:

sampleArray[2] = 10;

Multidimensional Arrays

This is an array of arrays.

int samplearray = new int[4][5];

To access an element of this multidimensional array try to imagin this array like this

00  01  02  03  04
10  11  12  13  14
20  21  22  23  24
30  31  32  33  34

Categories: Java

Leave a Reply

%d bloggers like this: