File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vectors vs Array Lists

 
Rick Harrison
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good evening to all -
Which is better to use when retrieving rows from a database for
processing (max 100 rows): Vectors or Array Lists?
Thank you
 
Frank Carver
Sheriff
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main difference is that all access to a Vector is synchronized, which is slower, but safer in a multi-threaded environment. If you are not using threads, or have protected your access in another way, ArrayList is a better choice.
The only other thing to be careful of is Vector is part of Java 1.0 and 1.1, but ArrayList was only added in Java 1.2 and 1.3, so if you write code using ArrayList (or any of the collections API) you need at least a Java 1.2 VM.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic