Code example for Vector

Methods: isEmpty, lastElement, setSize, size

0
   */ 
  public synchronized Object getInstanceIfFree()
  { 
 
    // Check if the pool is empty. 
    if (!freeStack.isEmpty())
    { 
 
      // Remove object from end of free pool. 
      Object result = freeStack.lastElement();
 
      freeStack.setSize(freeStack.size() - 1);
 
      return result;
    } 
 
    return null; 
  } 
 
  /** 
   * Get an instance of the given object in this pool