1 public class Solution { 2 /** 3 *@param A: A list of integers 4 *@param elem: An integer 5 *@return: The new length after remove 6 */ 7 public static int removeElement(int[] aA, int elem) { 8 if (aA == null || aA.length == 0){ 9 return 0; 10 } 11 int count = 0; 12 for (int i=0; i < aA.length; i++){ 13 if (elem != aA[i]){ 14 aA[count++] = aA[i]; 15 } 16 } 17 return count; 18 } 19 }