answersLogoWhite

0

Both of these types of Collections allow for a new instance to be created with the contents of another Collection.

// This method will accept a Vector and return a new ArrayList which contains all elements of that Vector

static ArrayList toArrayList(Vector v) {

return new ArrayList(v);

}

// This method will accept an ArrayList and return a new Vector which contains all elements of that ArrayList

static Vector toArrayList(ArrayList al) {

return new Vector(al);

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

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 is an anagram for vector?

"Convert" is an anagram for vector.


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.


What is the difference between arrayList and vector in java?

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.


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.


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.


convert to vector?

We are a team of highly skilled, experienced graphic designers specializing in the field of  vector graphics. 


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);


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.


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.


What happens when you pass an object as an argument to addAll fucntion of arraylist?

If the passed object extends Collection, then all the objects in collection are added to the arraylist.


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);