.

Java Tutorial: Array in Java

Array

Array is collection same data type with sequential order. It is used to declare and access collection of variables.

Declare arrays:

First we have to specify the datatype then an identifiername.

Syntax:

Datatype [] variablename;

Example:

Int [] numers;

Creating array:

Using new keyword, array shall be generated

Syntax:

Datatype [] variablename= newdatatype[ size_of_an_array];

Example:

double [] numbers= new double [10];

Example program:

array img1
.