answersLogoWhite

0

What is arry as in java?

User Avatar

Anonymous

15y ago
Updated: 8/17/2019

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]);

}

User Avatar

Wiki User

15y ago

What else can I help you with?