先上码package arrayUtility;public class Insert<E> {
protected E value;
protected int position;
protected Object[] arr;

public Insert (E value, int position, Object[] arr){
this.value=value;
this.position=position;
this.arr=arr;
if(position<0 ||position>=arr.length)
throw new IndexOutOfBoundsException();
else if(position==arr.length-1)
this.insert();
else{
this.resize();
this.replace();
this.insert();
}
}

private void insert()
{
arr[position]=value;
}

private void resize()//resize the given array with a new length.
{
int newLength=arr.length+1;
Object[] temp=new Object[newLength];
System.arraycopy(temp, 0, arr, 0, arr.length);
arr=temp;
}

private void replace()
{
for(int i=arr.length-2;i>position;i--)
{
arr[i+1]=arr[i];
}
}
}我是想让这个class可以兼容所有类型的array(String[], int[]等等), 但是我跑main的时候用char[]貌似不行,求大神帮检查下我的错误。小弟刚学JAVA不久!