> But my question is: there are BOTH java.util.Vector.add(obj) and
> java.util.Vector.addElement(obj) in Java2 API. What are the difference?
> Other than the return values, can they replace each other? Thanks a lot

  According to the JDK source code, (and associated documentation)
they are identical except for the return values:

 /**
     * Adds the specified component to the end of this vector, 
     * increasing its size by one. The capacity of this vector is 
     * increased if its size becomes greater than its capacity. <p>
     *
     * This method is identical in functionality to the add(Object) method
     * (which is part of the List interface).
     *
     * @param   obj   the component to be added.
     * @see        #add(Object)
     * @see        List
     */
    public synchronized void addElement(Object obj) {
        modCount++;
        ensureCapacityHelper(elementCount + 1);
        elementData[elementCount++] = obj;
    }


    /**
     * Appends the specified element to the end of this Vector.
     *
     * @param o element to be appended to this Vector.
     * @return true (as per the general contract of Collection.add).
     * @since JDK1.2
     */
    public synchronized boolean add(Object o) {
        modCount++;
        ensureCapacityHelper(elementCount + 1);
        elementData[elementCount++] = o;
        return true;
    }
---------------------------------------------------------------------------
Send administrative requests to [EMAIL PROTECTED]

Reply via email to