// 獲取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)
更新元素的非法區(qū)間是:在索引 0 的左邊,大于或等于索引 size ;
在此區(qū)間的元素為查詢的合法元素;
// 修改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;
}