This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

difference between ArrayList - Vector  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to make an array where the size is variable.
What's the difference when I use an ArrayList or a Vector?
 
author and iconoclast
Sheriff
Posts: 24220
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sofie,
Vector is older; ArrayList was introduced with JDK 1.2. The main difference is that Vector's methods are synchronized, while ArrayList's are not. Synchronized methods effect how the class will behave in a multi-threaded program. They make the class "safer," but at the expense of a little performance.
Most new code should use ArrayList. If you need a synchronized list, you can use Collections.synchronizedList(myArrayList). There's little reason to use Vector in new code (except when you need one to pass to an older method that wants a Vector as an argument.)
I'm going to move this to the Java in General (Intermediate) forum, where this discussion would be more at home.
[ February 20, 2004: Message edited by: Ernest Friedman-Hill ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!