aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Vector" Watch "Vector" New topic
Author

Vector

Marcos Vilela
Greenhorn

Joined: Jul 06, 2005
Posts: 18
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

Joined: May 31, 2005
Posts: 519

The Vector implementation is basically an ArrayList, but is thread-safe, so insertion order will be the order you get byt default.


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD, SCEA/OCMJEA

Live life to an interface, not an implementation!
lauren bai
Greenhorn

Joined: Apr 08, 2005
Posts: 18
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)


SCJP (In Progress)
 
Consider Paul's rocket mass heater.
 
subject: Vector