Initialize Declare integer array in Android Java

How to create int array inside MainActivity.java programming file and assign-insert elements to array.

Array is one of the most popular data storing method available on all programming languages because array is used to store single type of multiples values inside only single variable and can be easily access again using its Index. Index is the location map of array elements and always starts with 0,1,2,3,4,5,n. An array can be defined as user requirement. So here is the complete step by step tutorial for Initialize Declare integer array in Android Java.

Initialize Declare integer array in Android Java

How to Initialize Declare integer array in Android Java.

Declaring array .

 int[] IntegerArray = new int[5];

Assign values to array .

IntegerArray[0] = 1;
IntegerArray[1] = 2;
IntegerArray[2] = 3;
IntegerArray[3] = 4;
IntegerArray[4] = 5;

Run Time define + Assign values to array .

 int[] IntegerArray = new int[] {1,2,3,4,5,6,7,8,9};