what is the difference between ArrayList and Vector

Answer Posted / vikas

1. Vector is synchronized while ArrayList is not.
2. Vector has default size is 10 while ArrayList has 10(Look
Java Class).
3. We can specify increment size with Vector.
4. If we use ensureCapacity(int minCapacity) to set the
default increment size then remember following things:
a. Vector v = new Vector();
b. V.capacity(); === output will be 10
c. If you try to set v.ensureCapacity(5),then
d. V.capacity(); ===10
e. If you try to set v.ensureCapacity( >20), then
f. V.capacity();===20 and
g. If you try to set v.ensureCapacity(21), then
h. V.capacity();===21, It clears that if set capacity over
20 then it will be set otherwise no.

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What java is used for?

847


What is the purpose of using break in each case of switch statement?

795


What are different types of references?

764


Discuss different types of errors that generally occur while programming.

810


What are static variables and functions?

852


What do you understand by java virtual machine?

937


What do you understand by the bean persistent property?

785


What are static initalizers in java ?

795


What is the full form of jpeg?

748


Can we have this () and super () together?

808


What is tree in java?

682


Which sorting is used in arrays sort in java?

887


Can private members of a base class are inheritable justify?

702


How can a gui component handle its own events?

828


What is encapsulation in java?

870