```
public class Solution {
public int removeElement(int[] nums, int val) {
int index = 0;
int count_val = 0;
int len = nums.length;
for(int i = 0; i < nums.length; i++){
if(nums[i] == val){
len--;
}
if(nums[i] != val){
nums[index] = nums[i];
index++;
}
}
return len;
}
}
```