Two Laptop Bag
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
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply locked New topic

ArrayList & Vector

Amrita Puja

Joined: Sep 27, 2006
Posts: 10

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.

Chris Hurst
Ranch Hand

Joined: Oct 26, 2003
Posts: 443

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

Joined: Sep 28, 2004
Posts: 20535

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.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
I agree. Here's the link:
subject: ArrayList & Vector
It's not a secret anymore!