public synchronized boolean removeLast(K obj){
  if (peekLast() != obj) {
    return false;
  }
  array=Arrays.copyOf(array,array.length - 1);
  return true;
}

public synchronized boolean removeLast ( K obj ) { if ( peekLast ( ) != obj ) { return false ; } array = Arrays . copyOf ( array , array . length - 1 ) ; return true ; }
remove the last element , if it matches .
