Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between Vector and ArrayList

Status
Not open for further replies.

varavoorvishnu

Programmer
Sep 9, 2002
45
Hi All,
I found that in one of the site the difference between Vector and ArrayList.
The explanation given is
1."Vector,a Heavyweight and ArrayList is Lightweight".
and
2.Another one is Vector-Synchronized and ArrayList-unsynchronized.
I understood the second ,but I found difficult with the first answer.

My doubt is :
1.How do u define "Heavyweight " and "Lightweight" objects? What are they?
2.What does it have to do with Collections?

Regards,
Vishnu
:)
 
1. Vector and ArrayList are lists implementation. Synchronized
means "thread safe" which adds a performance hit(heavy weight). On the other hand, ArrayList is not "thread safe". I use arrayList a lot more because I usually need it to display a bunch of read-only database records. If you need to do manipulations, and still want to make sure that it is thread-safe, then use Vectors.

what is a thread safety?

~za~
You can't bring back a dead thread!
 
opp..

all these items fall under Collections

Collection
|
List
/ / Vector ArrayList



~za~
You can't bring back a dead thread!
 
Hi Maxpower,
Thanx for the answers that u have given,
Now after reading ur points,I came to an understanding that
if thread is synchronized which inturn means more time consuming..so the time is the concern and hence u call it as heavy weight coz tht would reduce the performance.

Plz reply me bak stating if my understanding is right!!
Vishnu

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top