I'm trying to get the number of nodes per node by ID. you know, here's what I have

public Node getChildren(int id) { Node retNode = new Node(); if(First != null) { retNode = First; First = retNode; } else { retNode = last; last = retNode; } getChildren(id); return retNode; }

now if i remove the recursive call to getChildren(id) it works but it returns the same node as many times as there are children in the node

so i have this:

Node root = new Node("Root"); Node child = root.addChildToBack("Eggman"); Node Child2 = root.addChildToBack("Sonic"); Node child3 = root.addChildToFront("Tails"); Node child4 = child.addChildToBack("Snively"); Node child5 = Child2.addChildToBack("Sally"); String message = "Root node has: " + root.getChildrenCount() + "\n" + "Child Node has: " + child.getChildrenCount() + "\n" + "Child Node 2 has: " + Child2.getChildrenCount() + "\n" + "Child Node 3 has: " + child3.getChildrenCount() + "\n"; JOptionPane.showMessageDialog(null, message); for(int x = 0; x < root.getChildrenCount(); x++) { Node c = root.getChildren(x); JOptionPane.showMessageDialog(null, " " + c.getName()); }

now, as u can see it'll get tails 3 times since that's how many children the root has. any advice?