what is the diff b/w arraylist and vector?

Answer Posted / umanath

Vector and ArrayList are very similar. Both of them
represent a 'growable array',
ArrayList it's part of the Java Collection Framework, and
has been added with version 1.2, Vector it's an object that
is present since the first version of the JDK.
The main difference is that Vector it's a synchronized
object, while ArrayList it's not.
While the iterator that are returned by both classes are
fail-fast (they cleanly thrown a
ConcurrentModificationException when the original object has
been modified), the Enumeration returned by Vector are not.

Unless you have strong reason to use a Vector, the
suggestion is to use the ArrayList.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is skeleton and stub?

760


How many threads does a core java have?

775


How do you include a string in java?

750


Mention the default values of all the elements of an array defined as an instance variable.

732


What are the properties of thread?

685


What is methodological theory?

751


How do you convert boolean to boolean?

787


Which is dependent variable?

666


What is a function in programming?

773


How does singleton class work?

741


How do constructors use this() and super()?

799


What is foreach loop in java?

752


What is the purpose of a volatile variable?

755


Why are lists ordered in java?

776


What is immutable in java?

769