Visit: https://a2zcareers.viden.io
An array is a container object that holds a fixed number of values of a single type. An item in an array is called an element. Every element can be accessed via an index. The first element in an array is addressed via the 0 index, the second via 1, etc.
package com.vogella.javaintro.array;
public class TestMain {
public static void main(String[] args) {
// declares an array of integers
int[] array;
// allocates memory for 10 integers
array = new int[10];
// initialize values
array[0] = 10;
// initialize second element
array[1] = 20;
array[2] = 30;
array[3] = 40;
array[4] = 50;
array[5] = 60;
array[6] = 70;
array[7] = 80;
array[8] = 90;
array[9] = 100;
}
}