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

How do you add an element to an arraylist in java?

487


What is the use of default method in interface in java?

553


What is immutable in java?

544


What is anonymous inner class?

611


What environment variables do I need to set on my machine in order to be able to run java programs?

603






What is the meaning of flag day?

541


What is structure of java heap? What is perm gen space in heap?

544


Explain about static nested classes in java?

611


How many bytes is a string?

562


Explain wrapper classes in java?

534


Why string is not a wrapper class?

646


How do you do math powers in java?

577


How we can skip finally block of exception even if some exception occurs in the exception block in java?

526


What is the difference between a switch statement and an if statement?

517


How to perform linear search in java?

568