Vector add/addElement

The  addElement(E obj)  method is used to add the  specified component to the end of this vector  and increasing its size by one. The capacity of this vector is increased if its size becomes greater than its capacity. This  addElement()  method is identical in functionality to the  add(Object)  method. The add() method returns  true/false  but the addElement() method  does not return any value html

There's no difference, that's even mentioned in [the Javadoc|http://java.sun.com/javase/6/docs/api/java/util/Vector.html#addElement(E)] (ok, add() returns a boolean, addElement() doesn't, but they do the same thing).

addElement() is the old name from when Vector was first created. When the collections framework was introduced, Vector was changed to implement the List interface. The method with the same functionality in the List interface is called just add(), so Vector had to implement that as well.
java

相關文章
相關標籤/搜索