Chapter 8: Problem 11
8.11 A program has the following declaration: double[] values; Write code that asks the user for the size of the array and then creates an array of the specified size, referenced by the values variable.
/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none}
Learning Materials
Features
Discover
Chapter 8: Problem 11
8.11 A program has the following declaration: double[] values; Write code that asks the user for the size of the array and then creates an array of the specified size, referenced by the values variable.
All the tools & learning materials you need for study success - in one app.
Get started for free
8.12 Look at the following statements: int[] a = { 1, 2, 3, 4, 5, 6, 7 }; int[] b = new int[7]; Write code that copies the a array to the b array.
How do you insert an item at a specific location in an ArrayList object?
Recall that we discussed a Rectangle class in Chapter 6. Write code that declares a Rectangle array with five elements. Instantiate each element with a Rectangle object. Use the Rectangle constructor to initialize each object with values for the length and width fields.
8.15 a) Write a statement that declares a String array initialized with the following strings: 鈥淢ercury鈥, 鈥淰enus鈥, 鈥淓arth鈥, and 鈥淢ars鈥. b) Write a loop that displays the contents of each element in the array you declared in A. c) Write a loop that displays the first character of the strings stored in each element of the array you declared in A. (Hint: Use the String class鈥檚 charAt method discussed in Chapter 2.)
How do you remove an item from an ArrayList object?
What do you think about this solution?
We value your feedback to improve our textbook solutions.