Quick Reference 13
Terms in this set (19)
A class whose instances share many characteristics with an array. In particular, the elements — all of which are objects of data type E, where E is the name of some reference data type — of an ArrayList<E> instance are accessed via an index. Unlike an array, however, an ArrayList<E> object's length may be changed by inserting or deleting elements.
A class whose instances are pseudo-random number generators, capable of generating sequences of pseudo-random booleans or numbers of various types.
Formal Type Paramter
The symbolic expression (usually a single letter, such as E) that appears between the angle brackets in the name of a generic class (such as ArrayList<E>). When replaced by the name of an actual reference data type, it specifies the data type of all the elements that are contained in instances of the class in question.
A class (such as ArrayList<String>) whose data type designation includes a type parameter enclosed between angle brackets.
The (positive) integer argument provided to the ArrayList<E> constructor when a new ArrayList<E> instance is created. It warns the Java compiler to prepare itself for the instance to contain that number of elements. The actual size of the instance may subsequently be changed by the addition or removal of elements. If no initial capacity is provided, a default value of 10 is used.
Primitive Data Type
A Java data type that directly holds its value. Examples include boolean, double, int, and void. To each primitive data type there corresponds a wrapper class that is a reference data type.
Reference Data Type
A Java data type that is not a primitive data type. (Its value is indicated by a pointer or reference rather than being held directly.) Examples include Integer, String, and all classes that are defined in a Java program.
The name of a reference data type (such as String) appearing between a pair of angle brackets in the data type designation of a generic class.
A class that wraps the value of a primitive data type in the trappings of a reference data type. Examples include Integer and Double, which correspond respectively to the primitive data types int and double. To make it possible to store elements of a primitive data type in an instance of a generic class, the type parameter of that class must be the name of the wrapper class that corresponds to the primitive data type in question.
A 0- or 1-argument ArrayList<E> instance method that inserts a specified element of data type E either after the current last element of an ArrayList<E> object or at some specified index.
A 1-argument ArrayList<E> instance method that returns the element of an ArrayList<E> object at the specified index.
A 0- or 1-argument Random instance method that takes an optional (positive) integer argument and returns the next int generated by the Random object either from the full range of ints (if no argument is provided) or from 0 through one less than the argument (otherwise).
A 1-argument ArrayList<E> instance method that removes the element of an ArrayList<E> object at the specified index and returns the element thus removed.
A 2-argument ArrayList<E> instance method that replaces the element of an ArrayList<E> object at the specified index by the specified object of data type E and returns the element that has just been replaced.
A 0-argument ArrayList<E> instance method that returns an int giving the number of elements currently contained in an ArrayList<E> object.
Cannot fins symbol
When using either the add or the set method to add an element to or replace an element of an ArrayList<E>, if the new element is not of data type E or is not automatically cast or converted to data type E, then a cannot find symbol error is raised. (This happens, for example, when attempting to add a double to an ArrayList<Integer> object.)
Index out of bounds
Any attempt to reference an element of an ArrayList<E> instance using either a negative index or a positive index that is greater than or equal to the size of the instance causes program execution to be interrupted and a IndexOutOfBoundsException to be thrown.
Any attempt to reference an element of an ArrayList<E> instance when that element is null causes program execution to be interrupted and a NullPointerException to be thrown.
If the name of a primitive data type is used as the type parameter of a generic class, then an unexpected type error is raised. This is because every type parameter is required to be the name of a reference data type.