User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 455,985 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,801 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 960 | Replies: 4
Reply
Join Date: May 2006
Posts: 15
Reputation: java_programmer is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
java_programmer java_programmer is offline Offline
Newbie Poster

ArrayList or Vector ?

  #1  
Dec 3rd, 2007
Hi,
I have another question.
What is the advantage of arraylist over vector.
Why arraylist is widely used instead of vector in java programming?
Thanks in advance.....
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 19
Solved Threads: 200
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: ArrayList or Vector ?

  #2  
Dec 3rd, 2007
don't use Vector unless you have to and remember that you don't have to unless you've no other option (like it's a required argument to some method). That's all you need to know.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote  
Join Date: May 2006
Posts: 15
Reputation: java_programmer is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
java_programmer java_programmer is offline Offline
Newbie Poster

Question Re: ArrayList or Vector ?

  #3  
Dec 3rd, 2007
may be it is a legacy class. but I was asked both the questions in Interview.
That is why I need to know the answers.
Reply With Quote  
Join Date: Dec 2007
Posts: 6
Reputation: tommybobby is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
tommybobby tommybobby is offline Offline
Newbie Poster

Re: ArrayList or Vector ?

  #4  
Dec 3rd, 2007
Well in relation to threads, I major difference is that a Vector is synchronized and an ArrayList is not synchronized. What this means is, if two threads attempt to access a
Vector it will be synchronized. One thread will have to wait until the
other thread is finished accessing the Vector. With an ArrayList you have
to create wrappers to synchronize access to the ArrayList or you will have
undefined behaviour.

Also:

http://forum.java.sun.com/thread.jsp...sageID=4136184
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 19
Solved Threads: 200
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: ArrayList or Vector ?

  #5  
Dec 4th, 2007
Originally Posted by java_programmer View Post
may be it is a legacy class. but I was asked both the questions in Interview.
That is why I need to know the answers.


If you were asked that in a job interview and didn't know the answer they're right to fail you.
If you applied for a job where you should know the answer and you not only don't know it but don't know where to find it (and it's easy to find, everyone should know who's programmed in Java for more than a day or so) you don't deserve any job at all.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 9:24 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC