Reputation: 2096
Couldn't find any real answers on google.
Upvotes: 0
Views: 1627
Reputation: 104168
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.
Upvotes: 0
Reputation: 533492
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())
Upvotes: 2
Reputation: 597076
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.
Upvotes: 2
Reputation: 22415
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.
Upvotes: 5