code: public Object set(int index, Object element) {
  
          if (index >= elementCount) {
              throw new IndexOutOfBoundsException("Index out of bounds: "
                                                  + index + " >= "
                                                  + elementCount);
          }
  
          if (index < 0) {
              throw new IndexOutOfBoundsException("Index out of bounds: "
                                                  + index + " < 0");
          }
  
          Object replacedObj = elementData[index];
  
          elementData[index] = element;
  
          return replacedObj;
      }
docs: Replaces the element at given position