copyEvens

public int[] copyEvens(int[] nums, int count) {
  
  int newIndex=0;
  int i=0;
  int newArray[] = new int[count];
  while(newIndex < count ){
    if( ( nums[i] % 2) ==0  ) newArray[newIndex++]=nums[i];
    
    i++;
  }
  
  return newArray;
  
}

http://codingbat.com/prob/p134174

posted @ 2017-02-15 21:18  友哥  阅读(89)  评论(0编辑  收藏  举报