Arrays
What is?
- Data Structure consisting of a collection of elements
- Each is identified by an index
- Numbers call indices
- All data stored in an array must be of the same time
- IMPORTANT!!! When we code the index starts from 0 but on the AP the index starts from 1
Working with Arrays
- Declare
- Initialize
- Load
Syntax
//Declaring:
int [] myArray;
//Initializing;
myArray = new int [10];
- Declaring and Initializing in 1 line
//Declaring and Initializing in 1 line
int [] myArray = new int [10];
//Loading an Array Traditionally
myArray[0]=10;
myArray[1]=11;
//All at once
int [] myArray = {1,2,3,4,5,6,7};