Learn Java - Arrays and ArrayLists Cheatsheet - Codecademy
Learn Java - Arrays and ArrayLists Cheatsheet - Codecademy
Index
An index refers to an element’s position within an array. int[] marks = {50, 55, 60, 70, 80};
The index of an array starts from 0 and goes up to one
less than the total length of the array.
System.out.println(marks[0]);
// Output: 50
System.out.println(marks[4]);
// Output: 80
Arrays
In Java, an array is used to store a list of elements of the // Create an array of 5 int elements
same datatype.
int[] marks = {10, 20, 30, 40, 50};
Arrays are fixed in size and their elements are ordered.
System.out.println(studentList);
}
}
Print Share