File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes vector and array list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "vector and array list " Watch "vector and array list " New topic
Author

vector and array list

vishnu hiranamayee
Greenhorn

Joined: Feb 23, 2006
Posts: 17
Hi
Both vector and arraylist are growable arrays and the differnece is vector is synchronized and arraylist is not synchronized.
How is synchronization done in vectors.
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
Originally posted by vishnu hiranamayee:
How is synchronization done in vectors.


In the same way you synchronize your classes.
The set() method in Vector looks like this


Where as the set() method in ArrayList reads


Got the difference?


Mani
Quaerendo Invenietis
vishnu hiranamayee
Greenhorn

Joined: Feb 23, 2006
Posts: 17
public synchronized Object set(int index, Object element) {}

But in the API of vectors only
Object set(int index, Object element)
is given .

if we give
public synchronized Object set(int index, Object element) {}
then arraylist will also be synchronized?
Then what is the differnece between vector and arraylist?
vishnu hiranamayee
Greenhorn

Joined: Feb 23, 2006
Posts: 17
public synchronized Object set(int index, Object element) {}

But in the API of vectors only
Object set(int index, Object element)
is given .

if we give
public synchronized Object set(int index, Object element) {}
then arraylist will also be synchronized?
Then what is the differnece between vector and arraylist?
ak pillai
author
Ranch Hand

Joined: Feb 11, 2006
Posts: 288
Yes . Java Collections Framework remedies these problems and offers a number of advantages over using no framework or using the Vector and Hashtable


This article might help.

http://www.javaworld.com/javaworld/jw-11-1998/jw-11-collections.html


java j2ee job interview questions with answers | Learn the core concepts and the key areas
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: vector and array list
 
Similar Threads
Array List vs Vector
vector and array list
ConcurrentModificationException inside a synchronized method
elements inside arrays
performance : arraylist vs vector