0

Couldn't find any real answers on google.

Julian
  • 20,008
  • 17
  • 77
  • 108
Rab Ross
  • 2,098
  • 22
  • 28
  • Don't use Vector, Enumeration or Hashtable. They are ancient and should be avoided. Info: http://stackoverflow.com/questions/453684/use-hashtable-vector-or-hashmap-or-arraylist-in-java http://stackoverflow.com/questions/2601602/what-does-it-mean-when-we-say-hashtable-or-vector-is-synchronized http://stackoverflow.com/questions/2873254/difference-between-a-deprecated-and-legacy-api – Sean Patrick Floyd Dec 03 '10 at 16:40

4 Answers4

5

The documentation states it clearly:

[setElementAt] is identical in functionality to the set(int, E) method (which is part of the List interface). Note that the set method reverses the order of the parameters, to more closely match array usage. Note also that the set method returns the old value that was stored at the specified position.

http://download.oracle.com/javase/6/docs/api/java/util/Vector.html

EDIT: How I search Google for Java documentation is pretty simple. I type java 6 api String (replace String with whatever class you are wondering about) and it's usually the first hit.

Jeremy
  • 22,188
  • 4
  • 68
  • 81
2

set returns the original object at the given position.

Also, the set method appeared when the Vector class was retrofitted to conform to the List interface.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
2

The set() method was introduced when the Java 1.2 collections replaced legacy classes like Vector in 1998. They do the same thing, but perhaps its time to start using List if you can. (which just has set())

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
0

Have you read the API documentation? These are the same, with the exception that the set method returns the object previously at the specified position.

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
kgiannakakis
  • 103,016
  • 27
  • 158
  • 194