Asked in
Java Programming

What is arry as in java?

Answer

User Avatar
Wiki User
July 12, 2009 5:32PM

An array is a contiguous block of memory in which to store data. For instance, an array of integers is essentially a chunk of memory with integers stored one after another.

// Use [] to define an array of the given type.

int[] intArray;

// Instantiate intArray with enough space to hold 100 ints.

intArray = new int[100];

// Store some data...

int[0] = 100;

int[1] = 99;

int[2] = 98;

...

int[99] = 1;

// Retrieve some data...

for(int i = 0; i < intArray.length; ++i) {

System.out.println(intArray[i]);

}