File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "vector?" Watch "vector?" New topic


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

Joined: Aug 31, 2004
Posts: 11343

"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
John Dell'Oso
Ranch Hand

Joined: Apr 08, 2004
Posts: 130

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.

I agree. Here's the link:
subject: vector?
jQuery in Action, 3rd edition