dcsimg
Creating a constructor for a LinkedList
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   d_s
Posted On:   Saturday, April 6, 2002 07:53 AM

I am haveing trouble with this code:

Vector V = new Vector;
populate the Vector with Random Integers
LinkedList L = new LinkedList(V);

How do I create a constructor in my LinkedList program to accept the Vector as a LinkedList?

Re: Creating a constructor for a LinkedList

Posted By:   David_Cole  
Posted On:   Saturday, April 6, 2002 09:42 PM

I don't understand your question.
LinkedList does have a constructor which takes a Collection as a parameter, such as a Vector.


LinkedList L = new LinkedList(V) should work.


One thing though, unless you intended to use Vector because it is synchronized, for performance reasons you should try using java.util.ArrayList instead.


If this doesn't help...maybe you could explain your question in more depth.


Dave

About | Sitemap | Contact