// 获取index索引位置的元素
public int get(int index){
if(index < 0 || index >= size)
throw new IllegalArgumentException("Get failed. Index is illegal.");
return data[index];
}
更新 - void set(int index, int e)
更新元素的非法区间是:在索引 0 的左边,大于或等于索引 size ;
在此区间的元素为查询的合法元素;
// 修改index索引位置的元素为e
public void set(int index, int e){
if(index < 0 || index >= size)
throw new IllegalArgumentException("Set failed. Index is illegal.");
data[index] = e;
}