• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vector

 
Marcos Vilela
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following classes, will return elements in the order they were added (first in first out) when accessed via an iterator?

Vector. True
LinkedHashSet. True.

Why Vector?




output = Two , Ten , Three , One.

It's a little trick because if you use add with a position it will be wrong..

I need help..

Thanks
 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Vector implementation is basically an ArrayList, but is thread-safe, so insertion order will be the order you get byt default.
 
lauren bai
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a little trick because if you use add with a position it will be wrong..

I don't know why you change the position since it's not the question said
in the order they were added (first in first out)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic