Arrays Flashcards
What does an array represent?
Arrays represent a collection of data.
Is an array a value type or reference type?
Reference type
How do I know how many elements are in an array?
A single array variable can track any number of individual data items. It’s only limited by the computer’s memory.
How do I know how many elements an array could hold?
By the int in the square brackets or by .length();
How do I access an element in an array?
Through the array’s index.
Ex: System.out.println(planets[1]);
If an array holds ten elements, what happens if I try to access the 12th element?
An index that is greater than or equal to the length of the array will cause a run-time failure. A negative index will causes a run-time failure.
Are array elements value or reference types?