public synchronized boolean retainAll(Collection c){
  Object[] elements=getArray();
  int len=elements.length;
  if (len != 0) {
    int newlen=0;
    Object[] temp=new Object[len];
    for (int i=0; i < len; ++i) {
      Object element=elements[i];
      if (c.contains(element))       temp[newlen++]=element;
    }
    if (newlen != len) {
      setArray(copyOfRange(temp,0,newlen,Object[].class));
      return true;
    }
  }
  return false;
}

public synchronized boolean retainAll ( Collection c ) { Object [ ] elements = getArray ( ) ; int len = elements . length ; if ( len != 0 ) { int newlen = 0 ; Object [ ] temp = new Object [ len ] ; for ( int i = 0 ; i < len ; ++ i ) { Object element = elements [ i ] ; if ( c . contains ( element ) ) temp [ newlen ++ ] = element ; } if ( newlen != len ) { setArray ( copyOfRange ( temp , 0 , newlen , Object [ ] . class ) ) ; return true ; } } return false ; }
retains only the elements in this list that are contained in the specified collection . in other words , removes from this list all of its elements that are not contained in the specified collection .
