A good answer might be:

val[3] == 25.5

Initializer Lists

You can declare, construct, and initialize the array all in one statement:

int[] data = {23, 38, 14, -3, 0, 14, 9, 103, 0, -56 };
This declares an array of int which will be named data, constructs an int array of 10 slots (indexed 0..9), and puts the designated values into the slots. The first value in the initializer list corresponds to index 0, the second value coresponds to index 1, and so on. (So in this example, data[0] gets the 23.)

You do not have to say how many slots the array has. The compiler will count the values in the initializer list and make that many slots. Remember that once an array has been constructed, the number of slots it has does not change. (But of course you can change what is in the slots.)

QUESTION 10:

Write a declaration for an array of double named "dvals" that is initialized to contain 0.0, 0.5, 1.5, 2.0, and 2.5.

Click Here after you have answered the question