Array - StarShipTutor/StarshipTutorAPCS GitHub Wiki
docs.oracle.com
Array :Variable Declaration and Initialization
// Inline
int[] data = { 1, 2, 3};
// or
int[] data;
data = new int[] { 1, 2, 3};
// or
int[] data;
data = new int[3];
data[0] = 1;
data[1] = 2;
data[2] = 3;
// length is a predefined parameter
int theArrayLength = data.length;
// Arrays are Iterable
int[] data = { 1, 2, 3};
for (int arrayValue : data)
{
System.out.println ( arrayValue );
}
Some Useful Static Methods
import java.util.Arrays;
boolean Arrays.equals ( anArray, anotherArray ); // numerically
boolean Arrays.compare ( anArray, anotherArray ); // lexicographically
int[] Arrays.copyOf ( int[] anArray, newLength); // copy with pad or truncate
String Arrays.toString ( anArray );
// Search and Sort
int index = Arrays.binarySearch ( int[] anArray, int key); // search
Arrays.sort ( int[] anArray ); // sort ascending
See the full list at docs.oracle.com