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
Is object a data type?
What is the size of boolean variable?
Make a data structure and implement an algorithm to print all the files in a directory. (The root directory can have sub-directories too.)
What is synchronization and why is it important in java programming?
Is 0 a real number?
What is considered an anti pattern?
Describe method overriding
What are register variables what are the advantages?
What is consumer in java?
Can arraylist contain null values?
What is overloading and overriding in java?
What is difference between array and arraylist in java?
How to remove the trailing spaces from a string?
Can we use catch statement for checked exceptions when there is no chance of raising exception in our code?
Is it necessary for the port addresses to be unique? Explain with reason.