数组的长度是固定的,所以应该是无法实现插入功能的。
为什么不用List呢?

解决方案 »

  1.   

    在數組中進行插入操作開銷較大﹐建義使用LinkedList
      

  2.   

    可以将r[2]以后的元素依次往后移动
    再r[2]=p;
    for(int i=0;i<r.lenth;i++) 
       r[i]=new MEM_BLK(i);
    for(i=r.lenth;i>=3;i--) 
       r[i]=r[i-1];
    MEM_BLK p=new MEM_BLK(65);
    r[2]=p;
    原数组中最后一个元素溢出。
    这样开销大,建议使用楼上的意见
      

  3.   

    insert into x[i]y[] = new X[x.length + 1] //X is the Type/ClassName of x, 
    System.arraycopy(x, 0, y, 0, i);
    y[i] = newValue;
    System.arraycopy(x, i, y, i + 1, x.length - i);
    x = y;
      

  4.   

    楼主这么做有什么用呢?
    考试吗?真要是这样, shine333(shine) 是个不错的主意!
    .arraycopy这个方法开销会小一些