Ch. 6 Flashcards
(49 cards)
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
What determines the array length in an initializer list?
The number of elements initially input
Can an array be a parameter?
Yes, it can be fed into a method
What happens if you change an array element in a method?
They are all changed
What is a command line argument?
Doing something with java in DOS. This can make life easier if you do it in a batch file
What is necessary when you do a sting array?
Each thing is added individually