aspose file tools*
The moose likes Threads and Synchronization and the fly likes ArrayList & Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply locked New topic
Author

ArrayList & Vector

Amrita Puja
Greenhorn

Joined: Sep 27, 2006
Posts: 10
Hi.

Difference between arraylist and vector is that, arraylist is synchronized where as vector is synchronized, in arraylist when the data added increases array size will increase, but in vector when initial size should be specified, if we add more data to it, it will double the size giving more allocations.

According to my knowledge, these are the diffrences i know.

Please tell me these differences are correct or not. If more differences are there, post those answers.

If arraylist is not synchronized, how we can do it synchronized.

If already list is there, what is the need of arraylist.

Thankyou.
Chris Hurst
Ranch Hand

Joined: Oct 26, 2003
Posts: 396

RE : If arraylist is not synchronized, how we can do it synchronized.

Use the apporpiate synchronized collection decorator

i.e. static method synchronizedList in the Collections class


"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18101
    
  39

Please do not crosspost. It wastes people's time and effort, as we can't tell if a question has already been answered.

Anyway, since the beginner forum is more appropriate, I am closing this topic.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayList & Vector
 
Similar Threads
Differences between vector and arraylist
what is the difference between arrays,vector and Array List?
what is the use of different collections..
ArrayList & Vector
ArrayList vs Vector