Go Back   Velocity Reviews > Newsgroups > Java
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Java - array to linklist

 
Thread Tools Search this Thread
Old 02-08-2004, 10:00 PM   #1
Default array to linklist


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.





jova
  Reply With Quote
Old 02-08-2004, 10:25 PM   #2
Andrew Thompson
 
Posts: n/a
Default Re: array to linklist
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/online...ollection.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




Andrew Thompson
  Reply With Quote
Old 02-08-2004, 10:47 PM   #3
Thomas Schodt
 
Posts: n/a
Default Re: array to linklist
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);


Thomas Schodt
  Reply With Quote
Old 02-08-2004, 11:35 PM   #4
jova
 
Posts: n/a
Default Re: array to linklist
the link class holds the next link in the list.

"Andrew Thompson" <> wrote in message
news:nHyVb.48255$...
> 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/online...ollection.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
>
>





jova
  Reply With Quote
Old 02-09-2004, 01:27 AM   #5
Tony Morris
 
Posts: n/a
Default Re: array to linklist


"jova" <> wrote in message
news:XjyVb.26861$...
> 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)




Tony Morris
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
constants as of array of integers, for loops octavsly Hardware 0 04-25-2009 11:53 AM
How to retrieve array parameter ( JAVA ) naruponk Software 1 04-16-2009 10:20 AM
Array Programme rits Software 2 03-04-2009 05:18 PM
synthesis error sekhar_kollati Hardware 0 11-13-2007 04:48 AM
need help Invalid length for a Base-64 char array rrwestva Hardware 0 07-04-2006 09:36 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46