Forums Register Login

ArrayList & Vector

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Not an advanced question. Moving...
+Pie Number of slices to send: Send
 

Difference between arraylist and vector is that, arraylist is synchronized where as vector is synchronized

False, ArrayList is unsynchronized.

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.

This depends on how you construct the Vector. Check java.util.Vector #capacityIncrement

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

List<E> synchronizedList = Collections.synchronizedList(new ArrayList<E>());

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

List is an interface, ArrayList is a basic implementation of this interface.
[ October 12, 2006: Message edited by: Bauke Scholtz ]
+Pie Number of slices to send: Send
Hi As you said, the differences you have given about Arraylist and Vector are perfect. Now about you queries If arraylist is not synchronized, how we can do it synchronized.?

If you want to make arraylist synchronized, you should use Collections.synchronizedCollection(Collection c) method or you can use Collections.synchronizedList(List list) method in the Collections class.

If already list is there, what is the need of arraylist? Amrita, check the API[java.util]. List is an interface which sets the rule where as Arraylist implements the List interface.

Regards Makarand
+Pie Number of slices to send: Send
Hi ranchers,


Vector came first. It was already introduced into Java in version v1.2.
Due to this, Vector still has the old method names like addElement. This method identifier (and the like) is/are not found in ArrayList.


Yours,
Bu.


p.m., hey, Makarandp, do you know, your member number is a prime?
+Pie Number of slices to send: Send
Hi Burkhard Hassel
"hey, Makarandp, do you know, your member number is a prime?" - i didn't get what you want to say. Can you come back please.

Regards
Makarand parab
+Pie Number of slices to send: Send
A prime number is divideable to a round number by 1 or itself only. Your member number 134857 is such one.
Also see http://en.wikipedia.org/wiki/Prime_number

Nothing to do with yourself
[ October 12, 2006: Message edited by: Bauke Scholtz ]
+Pie Number of slices to send: Send
ooohhhh
He was talking of "Member # 134857". Sorry i really didn't get that.
Good observation.

Regards
Makarand Parab
I don't even know how to spell CIA. But this tiny ad does:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1179 times.
Similar Threads
Differences between vector and arraylist
ArrayList vs Vector
what is the use of different collections..
what is the difference between arrays,vector and Array List?
ArrayList & Vector
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 08:08:48.