public boolean replace(int key,E oldValue,E newValue){
  if (oldValue == null || newValue == null) {
    return false;
  }
synchronized (this) {
    Object[] arr=array;
    if (arr.length <= key) {
      return false;
    }
    Object prev=arr[key];
    if (prev.equals(oldValue)) {
      arr[key]=newValue;
      array=arr;
      size++;
      return true;
    }
  }
  return false;
}

public boolean replace ( int key , E oldValue , E newValue ) { if ( oldValue == null || newValue == null ) { return false ; } synchronized ( this ) { Object [ ] arr = array ; if ( arr . length <= key ) { return false ; } Object prev = arr [ key ] ; if ( prev . equals ( oldValue ) ) { arr [ key ] = newValue ; array = arr ; size ++ ; return true ; } } return false ; }
replaces the entry for the specified key only if currently mapped to the specified value .
