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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!