> For the complete documentation index, see [llms.txt](https://ucan.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ucan.gitbook.io/notes/27.-remove-element.md).

# 27. Remove Element

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