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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "vector?" Watch "vector?" New topic
Author

vector?

Suka Hati
Ranch Hand

Joined: Oct 28, 2004
Posts: 56
can anybody explain to me what is Vector in java?does the function is the same with array???
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Vector.html


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
John Dell'Oso
Ranch Hand

Joined: Apr 08, 2004
Posts: 130
Suka,

You can view a vector as a "growable" array. That is, the vector grows or shrinks according to how many items your add or remove to or from it. The major difference is that you can only store objects (or object references) in a vector. An array can store primitive data types in addition to object references.

Having said that, you would be well advised to use the ArrayList class in place of a vector. The ArrayList is part of the Java Collections framework and is more efficient. Anything you can do with a vector, you can do with an ArrayList. The difference between the two collections is that Vector is synchronised whereas ArrayList (plus any of the other new collection implementations_ is not. From a beginner's learning point of view, this is not an issue. You can learn more about this when you learn about threads.

As suggested in a previous reply, check out the API documentation for these classes to learn more.

Regards,
JD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: vector?