Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 611 Bytes

File metadata and controls

25 lines (17 loc) · 611 Bytes

Arrays

Arrays are used to represent a fixed-size collection of things.

int[] oddNumbers = { 1, 3, 5, 7, 9 };

Fixed-size means that once an array is made, it will always hold the same number of things.

We call the things stored in an array its "elements."

You can make an array of any type of element by using the name of the type followed by [].

char[] letters = { 'a', 'b', 'c' };
String[] words = { "its", "as", "easy", "as" }
int[] numbers = { 1, 2, 3 };
double[] doubles = { 97.0, 98.0, 99.0, 1.0, 2.0, 3.0 };