answersLogoWhite

0


Best Answer

1)Synchronization: Vector is synchronized and arraylist are not. 2)Increment size: Vector can increment the size by double,arraylist can increment it by 50%.

2)The default size of vector has 10, arraylist have 0.

3)we can specify the increment size with the vector and with arraylist we can't.

4)Arraylist is very fast as it is non-synchronized.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

16y ago

A vector holds all data items in adjacent areas of memory, making transfer of the entire vector easy and insertion or deletion of items expensive when compared with lists. Lists hold items is disjoint areas of memory, making transfer of the entire list expensive but insertion and deletion of individual items relatively cheap. Classic vectors are also fixed in size, and limited to N items, while lists can dynamically grow and shrink. Vectors also offer indexed access to the element items. Lists don't. The classic vector's predecessor is an array. Modern implementations of vectors often aim at providing similar characteristic, but the underlying data structure may in fact be a list or a hash, and those vectors typically support dynamic re-sizing.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

ArrayList

Think of this as a growable array. It gives you fast iteration and fast random access. To state the obvious: it is an ordered collection (by index), but not sorted. You might want to know that as of version 1.4, ArrayList now implements the new RandomAccess interface-a marker interface (meaning it has no methods) that says, "this list supports fast (generally constant time) random access." Choose this over a LinkedList when you need fast iteration but aren't as likely to be doing a lot of insertion and deletion.

Vector

Vector is a holdover from the earliest days of Java; Vector and Hashtable were the two original collections, the rest were added with Java 2 versions 1.2 and 1.4. A Vector is basically the same as an ArrayList, but Vector methods are synchronized for thread safety. You'll normally want to use ArrayList instead of Vector because the synchronized methods add a performance hit you might not need. And if you do need thread safety, there are utility methods in class Collections that can help. Vector is the only class other than ArrayList to implement RandomAccess.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Arrays and Vectors are both designed to hold multiple values in them but they have one basic difference.

The main difference between them is the fact that Arrays is a homogeneous data type where it can hold only objects of one data type whereas Vectors are heterogeneous. You can have objects of different data types inside a Vector.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

ArrayList

Think of this as a growable array. It gives you fast iteration and fast random access. To state the obvious: it is an ordered collection (by index), but not sorted. You might want to know that as of version 1.4, ArrayList now implements the new RandomAccess interface-a marker interface (meaning it has no methods) that says, "this list supports fast (generally constant time) random access." Choose this over a LinkedList when you need fast iteration but aren't as likely to be doing a lot of insertion and deletion.

Vector

Vector is a holdover from the earliest days of Java; Vector and Hashtable were the two original collections, the rest were added with Java 2 versions 1.2 and 1.4. A Vector is basically the same as an ArrayList, but Vector methods are synchronized for thread safety. You'll normally want to use ArrayList instead of Vector because the synchronized methods add a performance hit you might not need. And if you do need thread safety, there are utility methods in class Collections that can help. Vector is the only class other than ArrayList to implement RandomAccess.

The only difference between the two is that Vectors are synchronized and hence threadsafe whereas ArrayLists are not. Otherwise they are both identical in terms of their features and usage.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

In use they're almost identical. The only thing you, as the programmer, really need to know is that Vectors are thread-safe and ArrayLists are not.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

An array has a fixed size, whereas the vector can grow in size as necessary.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

Vectors are thread safe while ArrayLists are not

ArrayLists are faster than Vectors

These are 2 main differences between ArrayLists and Vectors.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between arrayList and vector in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are the requirements to download a java arraylist?

The requirements to download a java arraylist are a pc with java software installed. A java arraylist is used to store a group of elements in a specific order.


How can you create array of an object in java?

Array's can hold only primitive data types. if you want a collection of objects you must use an ArrayList or a Vector.


How many number of objects we can store in an ArrayList. Is there any limit?

No. there is actually no such limit in any of the collections in java. The arraylist and vector are the most commonly used collections and they take thousands of objects. I have personally used them with atleast a 100,000 thousand objects.


What does it mean that a vector is synchronized in Java?

It means that multiple threads can safely read/modify data from a vector at the same time. Attempting to do that with an unsynchronized data type - an ArrayList, for instance - could result in an exception being thrown, or incorrect data being stored.


Collection framework in java?

Collection framework is a framework in java that helps us handle multiple java objects in one shot. For example if you have an employee validation system where you have details about all the employees in an office, you will have lets say 1000 employee objects available in an ArrayList which we can iterate and check if every employee that is going through the door is a valid employee. Some of the collections we can use are: a. ArrayList b. Vector c. HashMap d. HashSet e. etc

Related questions

Main difference between Array List and Vector in Java?

List is not sync'd as a vector is.


What are the requirements to download a java arraylist?

The requirements to download a java arraylist are a pc with java software installed. A java arraylist is used to store a group of elements in a specific order.


What type of platform does Arraylist Java run on?

Arraylist Java runs on Oracle which is a relational data management database produced by the Oracle Corporation. Arraylist Java has been part of the Java framework ever since Java 5.


How can you create array of an object in java?

Array's can hold only primitive data types. if you want a collection of objects you must use an ArrayList or a Vector.


How many number of objects we can store in an ArrayList. Is there any limit?

No. there is actually no such limit in any of the collections in java. The arraylist and vector are the most commonly used collections and they take thousands of objects. I have personally used them with atleast a 100,000 thousand objects.


What does it mean that a vector is synchronized in Java?

It means that multiple threads can safely read/modify data from a vector at the same time. Attempting to do that with an unsynchronized data type - an ArrayList, for instance - could result in an exception being thrown, or incorrect data being stored.


Collection framework in java?

Collection framework is a framework in java that helps us handle multiple java objects in one shot. For example if you have an employee validation system where you have details about all the employees in an office, you will have lets say 1000 employee objects available in an ArrayList which we can iterate and check if every employee that is going through the door is a valid employee. Some of the collections we can use are: a. ArrayList b. Vector c. HashMap d. HashSet e. etc


Use of java.util package?

The java.util package contains many useful utilities provided by the Java programming language. They include:Collections - ArrayList, Vector, HashMap etcEvent modelsDate & time featuresString tokenizerRandom number generatoretc.


How can you sort an arraylist of strings?

You can sort an ArrayList by using the sort method of the Collecions class (java.util.Collections). Assuming you have an ArrayList called foo: Collections.sort(foo);


What is subclasses in java?

Subclasses are classes that inherit from parent classes. i.e. ArrayList is a subclass of List.


How you can store a class variables in array list?

An (non generic) arrayList in java can save any type of object (in this case your class variable) in this straightforward way: MyClass myClassVar = new MyClass(); ArrayList myArrayList = new ArrayList(); myArrayList.add(myClassVar);


What is difference between java 2 and java 5?

They are different versions. Java 5 is newer than Java 2. Think of it like the difference between the Playstation 1 and the Playstation 3.