A better way to add and delete elements in arrays

  • Dynamic arrays (a.k.a. ArrayList in Java) consists of:

    1. A (fixed size) array

    2. A count of the actual number of elements stored in the array:

      Schematically:

      Currently, there are 2 values stored in the array