aspose file tools*
The moose likes Beginning Java and the fly likes Array vs Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array vs Vector" Watch "Array vs Vector" New topic
Author

Array vs Vector

Larry Lai
Ranch Hand

Joined: May 13, 2002
Posts: 44
Hi everyone,
What's the difference between array and vector?
What's the advantage and disadvantage of them?
thanks
Larry
Robert Ziel
Greenhorn

Joined: Apr 22, 2002
Posts: 28
look at the api's '
array cannot get larger vectors can
vector contains objects not primitives..
if you want to store primitives you should use a wrapper etc....
but then again look at the
Api
[ May 21, 2002: Message edited by: Robert Ziel ]
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Vectors can only store objects so you always need to cast when you take the object out of the vector. Arrays can be created to hold a specific type of object (Button[] b = new Button[10] . Arrays are almost always faster than vectors. Vectors are synchronized.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
"Behind every Vector is a good array"
In real life a Vector is a lot of bells and whistles and functionality around an array.
If you want the functionality provided for you - use Vector and accept the overhead.
If you uses are simple or you want to use primitives without putting them in wrappers - use arrays.
From the source code for Vector:


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array vs Vector
 
Similar Threads
difference between ArrayList - Vector
Regd Multidimensional arrays/collections
Difference between vector and array
can you have an array of vectors
why some classes are called deprecated & some legacy?