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

Detail discussions on JVM, memory management and garbage collector.

555


What is the access scope of protected access specifier?

539


How do you use substring in java?

547


What is the different between get and post?

501


Can a constructor have different name than a class name in java?

594






What is immutable state?

508


What is difference between string and stringbuffer?

496


What is ‘is-a ‘ relationship in java?

590


According to java operator precedence, which operator is considered to be with highest precedence?

603


What is the final class?

550


What is a programming object?

556


What is sleep method?

623


Is empty string in java?

544


Can we able to pass objects as an arguments in java?

535


How do you do exponents in java?

538