array to linklist

  • Follow


I'm stuck

I have to convert an array to a linklist

the array is initialized as

public Organization{
Crew[] members = new Member [10]

etc....

}
I'm trying to get it setup where Crew  holds it's members in a linkedlist


this is what I have so far.
public Organization{
private Link beforeAll = new Link(null,null);

etc...
}

I just can't figure out how to convert it.



0
Reply Email67 (21) 2/8/2004 10:00:23 PM

jova wrote:
> I'm stuck
....
> I'm trying to get it setup where Crew  holds it's members in a
> linkedlist
.....
> this is what I have so far.
> public Organization{
> private Link beforeAll = new Link(null,null);

What is 'Link' class?

> etc...
> }

It sounds like you either need the JavaDocs
http://java.sun.com/j2se/1.4.2/docs/api/ , the tutorials
http://java.sun.com/developer/onlineTraining/collections/Collection.html ,
news:comp.lang.java.help or all three.

One way to do it is to iterate through the
array and add each element to a Vector,
which, implementing Collection, can be
handed to the LinkedList in the constructor.

HTH

--
Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology


0
Reply SeeMySites (3836) 2/8/2004 10:25:23 PM


jova wrote:

 > I have to convert an array to a linklist

Use Arrays.asList().


Member[] ma = new Member[10];
....
List al = Arrays.asList(ma);
LinkedList ll = new LinkedList(al);
0
Reply Thomas 2/8/2004 10:47:51 PM

the link class holds the next link in the list.

"Andrew Thompson" <SeeMySites@www.invalid> wrote in message
news:nHyVb.48255$Wa.39344@news-server.bigpond.net.au...
> jova wrote:
> > I'm stuck
> ...
> > I'm trying to get it setup where Crew  holds it's members in a
> > linkedlist
> ....
> > this is what I have so far.
> > public Organization{
> > private Link beforeAll = new Link(null,null);
>
> What is 'Link' class?
>
> > etc...
> > }
>
> It sounds like you either need the JavaDocs
> http://java.sun.com/j2se/1.4.2/docs/api/ , the tutorials
> http://java.sun.com/developer/onlineTraining/collections/Collection.html ,
> news:comp.lang.java.help or all three.
>
> One way to do it is to iterate through the
> array and add each element to a Vector,
> which, implementing Collection, can be
> handed to the LinkedList in the constructor.
>
> HTH
>
> --
> Andrew Thompson
> * http://www.PhySci.org/ Open-source software suite
> * http://www.PhySci.org/codes/ Web & IT Help
> * http://www.1point1C.org/ Science & Technology
>
>


0
Reply Email67 (21) 2/8/2004 11:35:55 PM


"jova" <Email@nospam.net> wrote in message
news:XjyVb.26861$KV5.20264@nwrdny01.gnilink.net...
> I'm stuck
>
> I have to convert an array to a linklist
>
> the array is initialized as
>
> public Organization{
> Crew[] members = new Member [10]
>
> etc....
>
> }
> I'm trying to get it setup where Crew  holds it's members in a linkedlist
>
>
> this is what I have so far.
> public Organization{
> private Link beforeAll = new Link(null,null);
>
> etc...
> }
>
> I just can't figure out how to convert it.
>
>
>

@see java.util.Arrays#asList(Object[])


-- 
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)


0
Reply dibblego (423) 2/9/2004 1:27:49 AM

4 Replies
12 Views

(page loaded in 0.054 seconds)


Reply: