click below
click below
Normal Size Small Size show me how
Chapter 8
Arrays
Term | Definition |
---|---|
Array | A named list of data items that all have the same type |
Element | Each data item in an array |
Declaring Arrays | Ex1: double[] salesFigrues = new double[20];... Ex2: int[] idNums = new int[100]; |
Naming Arrays | Names start with lowercase letter and user uppercase letters to begin subsequent words. Often named using a plural noun and by adding a final word that implies a group |
Subscript(Index) | An integer contained within square brackets that specifies one of an array's elements. AN array's elements are numbered beginning with 0. Ex: salesFigures[0]; |
Out of Bounds | When you use a subscript that is too small(negative) or too large for an array. An error message is generated |
Initialization List | A list of values separated by commas and enclosed within curly braces which initialize and array. The size of array is assigned based on the number of values. No keyword new needed. Ex: int[] tenMults = {10, 20, 30, 40, 50, 60}; |
Populating an Array | Providing values for all the elements in an array |
Initializing an Array | You cannot directly initialize only part of an array. You either must initialize every element or none of them |
length Field | Contains the number of elements in the array. length is not an array method; it is a field. AN instance variable or object field such as length is also called a property of the object. Ex: scoreArray.length; |
Enhanced for Loop(foreach loop) | Allows you to cycle through an array without specifying the starting and ending points for the loop control variable. Ex: for(int val : scoreArray)... System.out.println(val); |
Parallel Array | One with the same number of elements as another and for which the values in corresponding elements are related |
Range Match | A process in which you compare a value to the endpoints of numerical ranges to find the category in which a value belongs |
Passed by Value | The individual array elements are passed by value; that is, ca copy of the value is made and used within the receiving method. When any primitive type(boolean, char, byte, short, int, long, float, or double) is passed to a method, the value is passed |
Reference Types | Arrays, like all nonprimitive objects, are reference types; this means that the object actually holds a memory address where the values are stored |