1)Examine the above code that creates the array:    a)How is the base type of the array specified?     b)How is the length of the array specified?    c)How many Strings are actually stored in the array after the array has been created?    d)How is the base type of the ArrayList specified?     e)How is the capacity of the ArrayList specified?    f)What is the capacity of the ArrayList?    g)What is the size of the ArrayList?

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE: The implementation of a queue in an array, as given in this chapter, uses the variable count to...
icon
Related questions
Question

1)Examine the above code that creates the array:

   a)How is the base type of the array specified? 

   b)How is the length of the array specified?

   c)How many Strings are actually stored in the array after the array has been created?

   d)How is the base type of the ArrayList specified? 

   e)How is the capacity of the ArrayList specified?

   f)What is the capacity of the ArrayList?

   g)What is the size of the ArrayList?

Recall that the code to create an array of Strings is:
String[] array
=
new String [3];
An ArrayList is similar to an arrays, except it is:
• Resizable, meaning that it will automatically grow when needed. Unlike an array that only has
unchangeable length, an ArrayList has:
o size: the number of items currently in the ArrayList
o capacity: the number of positions currently in the ArrayList
• A Java class with methods. We cannot use [] notation with an ArrayList.
Here is the code that creates an ArrayList of Strings:
ArrayList<String> list = new ArrayList<String>(3);
and here is how we might visualize that ArrayList of Strings:
Transcribed Image Text:Recall that the code to create an array of Strings is: String[] array = new String [3]; An ArrayList is similar to an arrays, except it is: • Resizable, meaning that it will automatically grow when needed. Unlike an array that only has unchangeable length, an ArrayList has: o size: the number of items currently in the ArrayList o capacity: the number of positions currently in the ArrayList • A Java class with methods. We cannot use [] notation with an ArrayList. Here is the code that creates an ArrayList of Strings: ArrayList<String> list = new ArrayList<String>(3); and here is how we might visualize that ArrayList of Strings:
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning