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...

The ____ category of the Insert panel is used to create and insert the most frequently used objects, such as images, templates, media elements, and tables.

A. Common B. Layout C. Application D. HTML

Computer Science & Information Technology

A cold boot is generally faster than a warm boot.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

CM assists in streamlining change management processes and prevents changes that could detrimentally affect the security posture of a system before they happen.  __________

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Which of the following expressions is not a unary expression?

A. x B. sizeof(x) C. +x D. -x E. float(x)

Computer Science & Information Technology