Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reg. Vector

 
Angela Narain
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does a Vector contain elements in sorted order?
It is an implementation of the List interface which
allows duplicate elements in sorted order.
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anjela,
Yes, the Vector will contain the elements in a sorted order.This is because the Vector implements the responsibility of the List interface, which maintains the ordered sequence of elements.
Hope this helps,
Sandeep
SCJP2, OCSD(Oracle JDeveloper), OCED(Oracle Internet Platform)
 
Guoqiao Sun
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Angela, Vector does not contain element in sorted order. Only class implementing SortedMap or SortedSet contain element in sorted order.
But Vector contains element in ordered way, which means you can access the element through index of position.

------------------
Guoqiao Sun
Sun Certified Programmer for Java™ 2 Platform
Try my mock exam¹ at my homepage.
 
Jennifer Warren
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please confirm who is right as now i'm confused.
thanks
Jennifer
------------------
 
Gurpreet Sachdeva
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
Guoqiao is right vector does not contain elements in sorted order.
Sandeep, sorted way is different from ordered way. As Guoqiao said Ordered way only means that you can access the element through index of position. It has no relation with sorting.
The best way is to try some code.
Regards
Gurpreet Sachdeva
For Mock Exams FAQ and some useful information about Bitshift operator, inner classes, garbage collection,etc please visit: http://www.go4java.20m.com

[This message has been edited by Gurpreet Sachdeva (edited September 04, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic