码迷,mamicode.com
首页 > 编程语言 > 详细

Java 数组中删除数据

时间:2017-12-09 00:03:26      阅读:271      评论:0      收藏:0      [点我收藏+]

标签:auto   数组   ack   method   new   oid   void   bsp   pac   

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]+" ");
   }
  
  
 }

}

Java 数组中删除数据

标签:auto   数组   ack   method   new   oid   void   bsp   pac   

原文地址:http://www.cnblogs.com/www-hsy-com/p/8007478.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!