Return to Coding in Java with artEoz – exercises

ArrayList class

  1. Make sure you have the geometrie resource. If necessary, see the Resources import webpage.
  2. The code below creates a list:
  1. What is the capacity of this list? ? key_48
    What is its size? key_48
  2. Add to the end of the code the following two statements:
  1. Two new items are added at index 1 and 0. What do you notice? key_48
  1. Delete the Point in position 2 and watch the evolution of the the list. What happened? key_48
    Select Unreferenced objects option to change the display of the memory diagram. What can you conclude? key_48
  2. The items in positions 5 and 6 are free (set to null). Add a Point to position 6. What happens? key_48
  3. In an iteration, add 10 points at the end of the list.
    Select Unreferenced objects option. What do you notice? key_48
  4. In an iteration, delete the first 5 points. Has the capacity changed? key_48
  5. Add at the end of the code the following statement:
  1. How do you assess the effectiveness of the add function without parameters? Is it constant or function of the size or capacity of the list? key_48
  2. How do you calculate the effectiveness of the add function with a position parameter? key_48

Back to java exercises list