what is the difference between ArrayList and Vector

Answer Posted / rama krishna dwadasi

VECTOR:
i)Vector is a legacy class and represents array data structure.
ii)Vector uses indexing notation to store values.
iii)Vector can grow and shrink dynamically.
iv)Vector is synchronized; multiple threads cannot access
the vector object concurrently. Only one thread can access
the Vector object at a specific time.
v)Duplicate values are allowed.
vi)Before to java 2 there was an interface called
Enumeration to visit the elements of Vector. But now we have
two interfaces to visit the elements of Vector. They are
Iterator and ListIterator.
vii) Vector elements can be accessed randomly because it
implements RandomAccess marker interface
viii) Values will be stored in the same order as inserted.
ix) The elements in Vector can be accessed by Enumeration,
Iterator and ListIterator.


ArrayList:

i)ArrayList is a new class used to store multiple objects.
ii)ArrayList uses array data structure internally to store
the elements.
iiiArrayList uses indexing notation to store
values(sequentially).
iv)ArrayList can grow and shrink dynamically.
v)Duplicate values are allowed.
vi)ArrayList is not synchronized.
vii)ArrayList elements can be accessed randomly because it
implements RandomAccess marker interface.
viii)Values will be stored in the same order as inserted.
ix)The elements in ArrayList can be accessed by Iterator and
ListIterator.

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an object class?

785


v-model life cycle

1838


Differentiate between array list and vector in java.

891


Can we sort a map in java?

780


Which graphs are functions?

729


Does constructor creates the object ?

817


Compare Mutex and Semaphore in java.

777


What do you mean by compiler?

825


What is meant by null and void?

752


What is gc()?

763


How do you change an int to a string?

768


What is ternary operator in java?

831


What happens when a thread cannot acquire a lock on an object in java programming?

805


If I don't provide any arguments on the command line, then what will the value stored in the string array passed into the main() method, empty or null?

1022


Can we overload run() method in java?

877