Glossaria.net

Glossary Java / Term

array

A collection of data items, all of the same type, in which each item's position is uniquely designated by an integer. There are two ways to create arrays in Java. The first uses new, and specifies how large the array should be:

byte octet_buffer[] = new byte[1024];
Button buttons[] = new Button[10];

The second way to create an array is with an initializer, which looks just like it does in C:

int lookup_table[] = {1, 2, 4, 8, 16, 32, 64, 128};

Java arrays are implemented as classes; they just aren't used as classes in the traditional sense of calling methods, and so on. Even though you won't find a class called Array in the Java API documentation, you can rest assured that under Java's hood there is an array class that is at least vaguely similar to the Vector class.

Permanent link array - Creation date 2022-01-03


< argument Glossary / Java ASCII >