![]() |
|
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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 |
|
|
|
#3 |
|
Posts: n/a
|
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); |
|
|
|
#4 |
|
Posts: n/a
|
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 > > |
|
|
|
#5 |
|
Posts: n/a
|
"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) |
|