Esempio n. 1
0
  public String set(int index, String newVal) {

    if (index < 0 || index >= size()) throw new IndexOutOfBoundsException();

    LLNode tmp = _head; // create alias to head

    for (int i = 0; i < index; i++) tmp = tmp.getNext();

    String oldVal = tmp.getCargo();

    tmp.setCargo(newVal);

    return oldVal;
  }