Ch. 6 Flashcards
What is the purpose of an array?
Help us organize large amounts of data
What type of thing is an array?
An object
What must be the same when working with 2 different arrays?
Their datatypes
What is an array?
An ordered list of values
Where does array indexing start?
0
How do you find the value of an array index?
name[location]
How do you overwrite an array value?
name[location]=whatever
What is an array element?
A value held in an array
What is necessary for all array elements?
They are the same datatype
Are there any datatypes an array doesn’t support?
No
How do you define an array?
int[]name=new int[length]
What should you always do with an array?
Make it a bit larger than needed just in case
What must we careful of when pulling array elements?
The index is in-bounds
What happens if we call an out-of-bounds index?
An exception is thrown
What is the max index?
1 less than the number of values held in the array
How do you find the length of an array?
name.length (just that)
What is name.length of an array?
The public length constant
What is an initializer list?
Making the array and defining its elements all in one shot.
int[]name={1,2,3,4,5]
What is necessary for an initializer list?
The data is in braces and separated by commas