1.
Q18: Put the following code in order to create a program that will declare and instantiate an ArrayList of 20 random Integer values between 1 and 100 and then calculate and print the average of the first 10 numbers.
add()
get(<expression>)
method call (remember evaluating expressions subgoals)
get
represents the index in the ArrayList. The size of the ArrayList is the number of elements contained. If the ArrayList is initially empty, the size is 0.
arrayListName.size() - 1
, inclusive; otherwise IndexOutOfBoundsException
occurs
arrayListName.get(index)
returns the value stored at that index
set(<expression>, value)
method call which will be the index for the element to be updated