Arrays
Arrays are a very useful data-type in all programming languages. Although their syntax and implementation (and therefore efficiency) vary between programming languages, the general tools and methods for manipulating them are very similar.
Java:
Arrays in java must be of fixed length.
A good resource for java arrays online is Java Language Specification[java.sun.com]
Creating an array
Last updated at 11:48 AM on Wednesday 5th September, 2007 by Administrator
To create an int array of length 4:
int[] array = new int[4];
Now to populate the array:
for(int i = 0; i < array.length; i++)
{
array[i] = i;
}
However if we wish to populate an array with fixed values, it can be hardcoded:
int[] array = {0, 1, 2, 3};
Comments (0)