o[i] = obj; size++;
}
public Object set(int i, Object obj) {
- if (i >= size) throw new IndexOutOfBoundsException(
+ if (i >= o.length) throw new IndexOutOfBoundsException(
"index "+i+" is beyond list boundary "+size);
- Object old = o[i]; o[i] = obj; return old;
+ Object old = o[i]; o[i] = obj;
+ size = Math.max(i+1, size);
+ return old;
}
public Object get(int i) {
if (i >= size) throw new IndexOutOfBoundsException(