类实现部分:
import java.util.Arrays;
public class MyArrayList {
public int []arr;//定义一个数组
public int usedSize;//数组存放数据计数器
public static final int intCapacity=10; //数组长度
public MyArrayList(){
this.arr=new int[intCapacity];
this.usedSize=0;
}
//打印顺序表display
public void disPlay(){
for (int i = 0; i <this.usedSize ; i++) {
System.out.print(this.arr[i]+" ");
}
System.out.println();
}
//(设置一个方法判断pos位置是否合法)
private boolean judgePos(int pos){
/* if (0>pos||pos>=this.usedSize){
return false;
}
return true;*/
return 0>pos||pos>=this.usedSize;
}
//判断数组是否已经满,满则扩容2倍
private boolean isFull