Java Reference
In-Depth Information
b. for (int i = 1; i < data.length; i++) sum =
sum + data[i] ;
c. for (int i = 0; i < data.length; i++)
if (data[i] == target) return i;
΢΢΢Exercise R7.13. Give an example of
a. A useful method that has an array of integers as a parameter that is
not modified.
b. A useful method that has an array of integers as a parameter that is
modified.
c. A useful method that has an array of integers as a return value.
Describe each method; don't implement the methods.
΢΢΢Exercise R7.14. A method that has an array list as a parameter can
change the contents in two ways. It can change the contents of individual
array elements, or it can rearrange the elements. Describe two useful
methods with ArrayList<BankAccount> parameters that change
an array list of BankAccount objects in each of the two ways just
described.
΢ Exercise R7.15. What are parallel arrays? Why are parallel arrays
indications of poor programming? How can they be avoided?
΢΢Exercise R7.16. How do you perform the following tasks with arrays in
Java?
a. Test that two arrays contain the same elements in the same order
b. Copy one array to another
c. Fill an array with zeroes, overwriting all elements in it
d. Remove all elements from an array list
΢ Exercise R7.17. True or false?
Search WWH ::




Custom Search