新手!求帮忙看下报错代码!
程序代码:
package zs1; public class zs17 { static int[] data={2,5,7,3,8,9,4,}; static int index=8; static void insert(int pos,int value) { if (index==data.length) expand(); for(int i=index;i>pos;i--) { data[i]=data[i-1]; } data[pos]=value; index++; } static void delete(int pos) { index--; for(int i=pos;i<index;i++) { data[i]=data[i+1]; } } static void expand() { int[] a=new int[data.length*2]; System.arraycopy(data,0,a,0,data.length); data=a; } static void print() { for(int i=0;i<index;i++) { System.out.print(data[i]+""); } System.out.println(); } public static void main(System[] args) { insert(2,1); print(); delete(1); print(); } }
我不知道是哪里错了,运行却一直报错!