function Iterator(array) {
      var index = 0;
      this.hasNext = function() {
        return index < array.length;
      };

      this.next = function() {
        return array[index++];
      };

      this.remove = function() {
        array.splice(index, 1);
      };
    }
An ArrayList stores a variable number of objects.

@param {int} initialCapacity optional defines the initial capacity of the list, it's empty by default

@returns {ArrayList} new ArrayList object