help meee pleeaaaseee!!..ASAP!!!

[b][red]This message was edited by broli929 at 2005-2-11 18:35:42[/red][/b][hr]
[b][red]This message was edited by broli929 at 2005-2-10 16:39:6[/red][/b][hr]
[b][red]This message was edited by broli929 at 2005-2-10 16:22:37[/red][/b][hr]
[b][red]This message was edited by broli929 at 2005-2-10 16:22:7[/red][/b][hr]
i am trying to do a simple room planner GUI program. I need to be able to connect components together and so, each components has an ArrayList in which to store the directly connected components. thus getting the directly connected components is easy enough, however, including the indirectly connected components needs a recursive method..or at least i thing so..
eg: if chairA is connected to chairB and chairB is connected to table, then calling this method for chairA, should return chairA and table.
I managed to make a recursive method which does compile but return an error when i try to run it, NullPointerException.

this is the code of the recursive part:

public Collection getList() {
return componentList;
}

public Collection getAllGroupElements() {
tempList1 = new ArrayList();
tempGetAll(componentList);
return tempList1;
}

private void tempGetAll(ArrayList t) {
RoomComponent component = new RoomComponent();

for (int i=0;i<t.size();i++) {
tempList1.add(t.get(i));
component = (RoomComponent) t.get(i);
component.tempGetAll((ArrayList)component.getList());
}

i also tried to initiate the two temporary vars, tempList and component in the constructor, however now it is giving me a StackOverFlow error instead of the other...

please help me!!






Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories