6.1 Array Lesson
6.1 Array Creation and Access
- Arrays are used to store one data type
- Unlike Arraylists, arrays have a fixed size and cannot be changed
- Arrays can be denoted using braces {} Below is an example of a simple array storing our scrum team names
[Meena, Shraddha, Madhumita, Pranavi]
To use an array you have to use the command
import java.util.Arrays;
dataType[] arrayName = new dataType[numberOfItems]; //Constructor
int[] arraySample = {1,3,5,7,9}; //pre-initialized arrays
arrayName.Length //determine the size
arrayName.length - 1 //to access the last item in the array