Code example for Vector

Methods: contains, indexOf, remove, setElementAt

0
        } 
        return null; 
    } 
 
    public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
        if (mChildNodes.contains(oldChild)) {
            // Try to remove the new child if available 
            try { 
                mChildNodes.remove(newChild);
            } catch (DOMException e) {
                // Ignore exception 
            } 
            mChildNodes.setElementAt(newChild, mChildNodes.indexOf(oldChild));
            ((NodeImpl)newChild).setParentNode(this);
            ((NodeImpl)oldChild).setParentNode(null);
        } else { 
            throw new DOMException(DOMException.NOT_FOUND_ERR, "Old child does not exist");
        } 
        return oldChild;
    }