Question: ArrayLists Write the lines of code needed to do each of the following tasks. (a) Declare a ArrayList object a with an initial capacity of

ArrayLists Write the lines of code needed to do each of the following tasks. (a) Declare a ArrayList object a with an initial capacity of 10 Integer objects. Next, append the integer 55 to a using the add method. (4 points) (b) The get method can be used to retrieve elements from an ArrayList. Using this method, find the sum of the first and last integers in a, and print it out to the screen. (4 points) (c) Suppose you declare an ArrayList with initial capacity 10. After appending 21 el- ements onto it, what is its new size and capacity? Remember that capacity doubles whenever maximum capacity reached. (2 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
