|
ArrayList
|
Vector
|
|
It
is not synchronized
|
Vector
is synchronized
|
|
In
case of single thread, ArrayList is faster than Vector
|
In
case of multiple threads, Vector is advisable, with single thread model
Vector becomes slow
|
|
ArrayList
increases it’s size by half every time
|
Vector
increase it’s size double
|
Showing posts with label Collection frame work questions. Show all posts
Showing posts with label Collection frame work questions. Show all posts
What is the difference between ArrayList and Vector?
What is the difference between Iterator and Enumeration?
|
Iterator
|
Enumeration
|
|
It is useful to
retrieve object
From a collection
|
It’s also useful
to retrieve object
From a collection
|
|
Iterator has
methods whose
Names are easy to
follow
|
Enumeration has
methods whose
Names are
difficult to remember
|
|
Iterator has an
option to remove
Objects from a
collection
|
Which is not
available
|
|
So Iterator is
preferred than Enumeration
|
|
What is the difference between Iterator and ListIterator?
- Both are useful to retrieve elements from a collection.
- Iterator can retrieve the elements only in forward direction.
- But ListIterator can retrieve the elements in forward and backward direction also.
- So ListIterator is preferred than Iterator
What is map in collection framework?
- Maps stored elements in the form of key and value pairs.
- If key is provided then its corresponding value can be obtained.
- Of course key should have unique values.
What is a queue in collections framework?
- A queue represents arrangements of elements in FIFO(Firs In First Out) order.
- This means that element that is stored as a first element into the queue will be removed first from the queue.
What is lists in collection framework?
- Lists are like Sets.
- They store a group of elements,
- But Lists allow duplicate values to be stored.
What is a set?
- A set represents a group of elements arranged just like an array.
- The set will grow dynamically when the elements are stored into it.
- A set will not allow duplicate elements.
- If we try to pass same element that is already available in the set, then it is not stored into it.
- Set will not maintain the same order of elements as in which they were entered.
Subscribe to:
Comments (Atom)