What is an array and a vector? How they different from each
other?

Answer Posted / ranganathkini

An array represents a contiguous block of memory where
objects are stored and accessed via a 0-based index value.
Arrays are usually fixed size once they are created.

A java.util.Vector is an implementation of a resizable
array. It has similar functionality as an array but also
gives the advantage of resizability when u try to add
elements to it exceeding its initial size.

The problem is that Vectors are synchronized which is not
necessary for many purposes and this may bring down
performance. Hence the use of ArrayList over Vecotor is
recommended. An ArrayList provides the same functionality of
a Vector, except tat it is not synchronized.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to write custom exception in java?

829


How do you invoke a method?

760


v-model life cycle

1841


Explain 5 features introduced in jdk 1.7?

828


What is flush () in java?

789


What's the difference between int and integer in java?

858


how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? : Java thread

771


When we should use serialization?

807


Can the interface be final?

782


Is space a character in java?

784


What value is a variable of the string type automatically initialized?

848


what is meant by abstract class?

858


What is the name of the java compiler?

803


What are the different ways of creating thread?

805


Is it safe to install java on my computer?

796