Java 数组中删除数据
package blue;
public class array {
public static void main(String[] args) {
// TODO Auto-generated method stub
int [] num={1,5,4,6,8,7,6};
int index=-1;
int [] num2=new int[7];
for(int i=0;i<num.length;i++){
num2[i]=num[i];
if(num[i]==4){
index=i;break;
}
}
for(int a = index;a<(num.length-1);a++){
num2[a]=num[a+1];
}
num[num2.length-1]=0;
for(int v=0;v<num.length;v++){
System.out.print(num2[v]+" ");
}
}
}