Write the statement to declare an ArrayList named myVals with a capacity of 15 items. Explain the importance of capacity when working with an ArrayList.
What will be an ideal response?
ArrayList myVals = new ArrayList(15);
An ArrayList's capacity is the number of items it can hold without having to increase its size. An ArrayList's capacity is greater than or equal to its size. It is more efficient to create an ArrayList with a larger capacity if you know you will need a specific number of items.
Computer Science & Information Technology
You might also like to view...
Pressing the ________ button will open the Join Properties dialog box
Fill in the blank(s) with correct word
Computer Science & Information Technology
The Internet is far too large for any router to hold routing information for all destinations. How does the Internet routing scheme deal with this issue?
What will be an ideal response?
Computer Science & Information Technology