Difference between Array and Vector
2 posts in topic
Flat View  Flat View

Posted By:   sateesh_divvela
Posted On:   Sunday, March 14, 2004 08:44 PM

What is the difference between arrays ansd vectors

Re: Difference between Array and Vector

Posted By:   Jordan_Koppole  
Posted On:   Monday, March 15, 2004 08:15 PM

1)Size of array need to be declared in advance.
2)Once declared array can't grow in size.
3)Array can store primitive data types.like int,char,...

1) No need to declare the size of vector. You may give its size & you may not.
2) Vector can always grow in size if you start adding more element to it than your declared size.
3) Vector can store only object references. Storing primitive data types is not possible in case of vectors.

Re: Difference between Array and Vector

Posted By:   David_Thornton  
Posted On:   Monday, March 15, 2004 04:31 PM

For starters from Sun;

"An array is a structure that holds multiple values of the same type. The length of an array is established when the array is created. After creation, an array is a fixed-length structure. "

"The Vector class implements a growable array of objects. Like an array, it contains components that can be accessed using an integer index. However, the size of a Vector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created."

For more detail see ;



About | Sitemap | Contact