public class ArrayApp {
public static void main(String[] args) {
long[] arr;
arr=new long[100];
long searchKey;
int i;
arr[0]=12;
arr[1]=3;
arr[2]=15;
arr[3]=72;
arr[4]=32;
arr[5]=452;
arr[6]=332;
arr[7]=752;
arr[8]=3542;
arr[9]=1322;
int nElements=10;
/***************************display********************************/
for (i=0;i<nElements;i++)
System.out.print(arr[i]+" ");
System.out.println(" ");
/***************************search********************************/
searchKey=20;
for (i=0;i<nElements;i++)
if (arr[i]==searchKey)
break;
if (i==nElements)
System.out.println("找不到"+searchKey);
else
System.out.println("找到了"+searchKey+"在"+i+"上");
/***************************delete********************************/
searchKey=135456;
for (i=0;i<nElements;i++)
if (arr[i]==searchKey)
{
System.out.println("找到数"+searchKey+ " 并删除之");
for(int k=i;k<nElements-i;k++)
arr[k]=arr[k+1];
nElements--;
}
/***************************display********************************/
for (i=0;i<nElements;i++)
System.out.print(arr[i]+" ");
System.out.println(" ");
}