title: JAVA Generic Tree Issue
body: <p>I am trying to understand generics and the tree structure and stuck on the following issue...</p>
  
  <p>I have created 3 classes
  1) Node
  2) Person
  3) NodeTest</p>
  
  <pre><code>import java.util.*;
  
  public class Node&lt;T&gt;
  {
      private Node&lt;T&gt; root; // a T type variable to store the root of the list
      private Node&lt;T&gt; parent; // a T type variable to store the parent of the list
      private List&lt;Node&lt;T&gt;&gt; children = new ArrayList&lt;Node&lt;T&gt;&gt;(); // a T type list to store the children of the list
  
      // default constructor
      public Node(){ }
  
      // constructor overloading to set the parent
      public Node(Node&lt;T&gt; parent)
      {
          this.setParent(parent);
          //this.addChild(parent);
      }
  
      // constructor overloading to set the parent of the list  
      public Node(Node&lt;T&gt; parent, Node&lt;T&gt; child)
      {
          this(parent);
          this.children.add(child);
      }
  
  
      public void addChild(Node&lt;T&gt; child)
      {
          this.children.add(child); // add this child to the list
      }
  
      public void removeChild(Node&lt;T&gt; child)
      {
          this.children.remove(child); // remove this child from the list
      }
  
      public Node&lt;T&gt; getRoot() {
          return root;
      }
  
      public boolean isRoot()
      {
          return this.root != null; // check to see if the root is null if yes then return true else return false
      }
  
      public void setRoot(Node&lt;T&gt; root) {
          this.root = root;
      }
  
      public Node&lt;T&gt; getParent() {
          return parent;
      }
  
      public void setParent(Node&lt;T&gt; parent) {
          this.parent = parent;
      }
  
      public boolean hasChildren()
      {
          return this.children.size()&gt;0;
      }
  
      public Node&lt;T&gt;[] children()
      {
          return (Node&lt;T&gt;[]) children.toArray(new Node[children.size()]);
      }
  
      public Node&lt;T&gt;[] getSiblings()
      {
  
          if(this.isRoot()==false)
          {
              System.out.println("this is not root");
          }
  
          List&lt;Node&lt;T&gt;&gt; tempSiblingList = new ArrayList&lt;Node&lt;T&gt;&gt;();
  
          //this.parent.children() isn't working for me
          //hence i tried to get around it next two lines
          Node&lt;T&gt; parent =  this.parent;
  
          Node&lt;T&gt;[] children =  parent.children();
  
          for(int i=0; i&lt;children.length; i++)
          {
              if(this!=children[i])
              {
                  tempSiblingList.add(children[i]);
              }
          }
          return (Node&lt;T&gt;[]) tempSiblingList.toArray(new Node[children.length]);
      }
  }
  
  
  
  
  
  
  public class Person {
  
      private String name;
      private int age;
      private String status;
  
      public Person(String name, int age, String status)
      {
          this.setName(name);
          this.setAge(age);
          this.setStatus(status);
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public int getAge() {
          return age;
      }
  
      public void setAge(int age) {
          this.age = age;
      }
  
      public String getStatus() {
          return status;
      }
  
      public void setStatus(String status) {
          this.status = status;
      }
  }
  </code></pre>
  
  <p>My question is how i can go about initializing the Node class Person class...</p>
  
  <p>i have tried</p>
  
  <pre><code>Person rootPerson = new Person("root", 80, "Alive");
  
  Node&lt;Person&gt; root = new Node&lt;Person&gt;(rootPerson);
  </code></pre>
  
  <p>but it isn't working for me...</p>
  
  <p>also need help with the getSibilings()</p>