• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference b/w Array, arraylist, vector

 
SJ Rao
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between Array, ArrayList, Vector ?
Need this info imm.. pl someone give me a clear picture.
Thanks in advance
SJ
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a quick nutshell...
I'd guess you did not mean java.sql.Array or java.lang.reflect.Array when you mentioned "Array". I'll assume you meant to refer to the typical array data structure in Java.
Try a quick search on this forum for "Vector ArrayList". You'll turn up quite a few explanations from past conversations. Note that the search page link is at the top right of this page.
Otherwise, you might want to spend a few moments reading the API documentation, the Arrays lesson of Sun's Java Tutorial, and the Collections Trail of Sun's Java Tutorial.
Good Luck
[ October 29, 2003: Message edited by: Dirk Schreckmann ]
 
SJ Rao
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Dirk, I got a lot of info in the "search".
SJ
 
praveenkumar singamsetty
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
arrays hold homogeneous objects
vectors hold heterogeneous objects
arraylist is like vector....in the sense it can hold heterogeneous object
but the api is good than that of vector....
vectors r by default threadsafe for arraylist u hav 2 implement them
ciao
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vectors r by default threadsafe for arraylist u hav 2 implement them
The Collections class provides an easy way to create a thread-safe List. This mechanism is referred to as a synchronization wrapper. To create a thread-safe List from an ArrayList, something similar to List mySynchronizedList = Collections.synchronizedList(myArrayList); should get the job done. (Note that both Vectors and Arraylists are Lists as each class implements the List interface.)
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should note that in general it is recommended that you never use Vector. Dirk explained the technique to use for a synchronized Collection.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic