public class Solution {

public int removeElement(int[] nums, int val) {

int m = 0;

int len = nums.length;

if(nums.length==0)

{

return 0;

}

for(int i=0;i<len;i++)

{

if(nums[i]==val)

{

m = m+1;

int j=0;

while(j+1<len)

{

nums[j]=nums[j+1];

j++;

}

len = len-1;

}

}

```
if(nums[len]==val)
{
m = m+1;
}
return nums.length-m;
}
```

}