Retainall Java

public void retainAll(int[] arr)
    {
       for (int i = 0; i < size; i++)
        {
            if(!Arrays.toString(arr).contains(Integer.toString(elementData[i]))){
                remove(i);
                i--;
            }
            
        }
    }
Sid Potti