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 many bytes is string in java?

618


What are the two ways of implementing multi-threading in java?

832


Justify your answer that you can't define a method inside another method in java, if you can then how?

608


Garbage collection in java?

609


Do I need java for windows 10?

559






How to reverse string in java?

623


What is sizeof () operator?

575


What is numel matlab?

668


Why synchronization is important?

596


What is the byte order of byte buffer?

572


What is an example of a boolean?

578


How will you communicate between two applets?

640


Explain the difference between map and flatmap stream operation?

823


Can a final variable be manipulated in java?

540


Which method you will use to create a new file to store some log data. Each time a new log entry is necessary, write string to the file in java ?

640