lettcode 第27. 移除元素
public static void main(String[] args) {
int[] array={1,3,3,4,5,6};
int a=1;
System.err.println(removeElement(array,a));
}
public static int removeElement(int[] array,int value) {
int tempLength=0;
if (array==null && array.length<=0){
tempLength=0;
}else {
for (int i=0;i<array.length;i++){
if (array[i]!=value){
array[tempLength]=array[i];
tempLength++;
}
}
}
return tempLength;
}