Originally posted by Mohit Goyal: A Vector maintains object refrences in the order they were added. ans given is true. According to me ans should be false because the Vector is ordered by index not by insertion order
The wording sounds a bit ambiguous to me. Well, let's see how a Vector maintains order of its elements. There're 3 methods that put a new element at the end of the vector so that the resulting order is in fact the insertion order:
And there're 2 other methods that allow you to insert element(s) at the specified position:
In both cases, the elements are accessible either through their indexes or the iterator() method. If the elements were added using the first group of methods, iterator() returns them in the order they were inserted.
Joined: Nov 09, 2003
Thanx Vad u really cleared my doubt. i was going through Khalid's book this evening in which it was given that Vector is ordered by insertion order. But I think u r right they ordered by both
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com