RemoveDuplicate { public static int removeElement(int[] nums, int val) { int newLen = 0; for (int i = 0; i < nums.length; i++) { if (nums[i] != val) { nums[newLen++] = nums[i]; } } return newLen; }  static int removeElement(int[] nums, int val);  }
@Test public void testRemoveDuplicate(int[] original, int k, int expectedLen, int[] expectedArray) { int len = RemoveDuplicate.removeElement(original, k); assertEquals(len, expectedLen); assertEqualsWithLen(original, expectedArray, len); }