Java Reference
In-Depth Information
2. You access array elements with an integer index, using the notation a[i] .
3. Index values of an array range from 0 to length - 1 . Accessing a
nonexistent element results in a bounds error.
4. Use the length field to find the number of elements in an array.
5. The ArrayList class manages a sequence of objects.
6. The ArrayList class is a generic class: ArrayList<T> collects objects of
type T .
7. To treat primitive type values as objects, you must use wrapper classes.
8. The enhanced for loop traverses all elements of a collection.
9. To count values in an array list, check all elements and count the matches until
you reach the end of the array list.
10. To find a value in an array list, check all elements until you have found a match.
11. To compute the maximum or minimum value of an array list, initialize a
candidate with the starting element. Then compare the candidate with the
remaining elements and update it if you find a larger or smaller value.
12. Two-dimensional arrays form a tabular, two-dimensional arrangement. You
access elements with an index pair a[i][j] .
13. An array variable stores a reference to the array. Copying the variable yields a
second reference to the same array.
14. Use the clone method to copy the elements of an array.
323
324
15. Use the System.arraycopy method to copy elements from one array to
another.
16. Avoid parallel arrays by changing them into arrays of objects.
17. A test suite is a set of tests for repeated testing.
Search WWH ::




Custom Search