Source of J9.11.java


  1: // @author Frank M. Carrano, Timothy M. Henry
  2: // @version 5.0

  4: public Object clone()
  5: {
  6:    AList<T> theCopy = null;

  8:    // Clone the list
  9:    try
 10:    {
 11:       @SuppressWarnings("unchecked")
 12:       AList<T> temp = (AList<T>)super.clone();
 13:       theCopy = temp;
 14:    }
 15:    catch (CloneNotSupportedException e)
 16:    {
 17:       throw new Error(e.toString());
 18:    }

 20:    // Clone the list's array
 21:    theCopy.list = list.clone();

 23:    // Clone the entries in the array (list[0] is unused and ignored)
 24:    for (int index = 1; index <= numberOfEntries; index++)
 25:    {
 26:       @SuppressWarnings("unchecked")
 27:       T temp = (T)list[index].clone();
 28:       theCopy.list[index] = temp;
 29:    } // end for

 31:    return theCopy;
 32: } // end clone