This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

vector and array list  RSS feed

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
vishnu hiranamayee
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
author
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
No, tomorrow we rule the world! With this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!