title: JAVA: how to pass an object within one object to another object?
body: <p>I need to pass an object (for example object from Class DATA) which is within another object (for example object from Class NODE) to another object (from class NODE)?
  The Node objects are nodes of a tree. The tree implementation is : </p>
  
  <pre><code>public class Tree {
  
  private Node rootElement;
  
  public Tree() {
      super();
  }
  
  public Node getRootElement() {
      return this.rootElement;
  }
  
  public void setRootElement(Node rootElement) {
      this.rootElement = rootElement;
  }
  </code></pre>
  
  <p>and then for Node I have: </p>
  
  <pre><code>public class Node {
  
  public MyNode data;
  public List&lt;Node&gt; children;
  public int  childNo;  
  
  public Node() {
      super();
  }
  
  public Node(MyNode data) {
      this();
      setData(data);
  }
  
   public Node(MyNode data, int childNo) {
      this();
      setData(data);
      this.childNo=childNo;
  }
  
  public void setChildren(List&lt;Node&gt; children) {
      this.children = children;
  }
  
  public void addChild(Node child) {
      if (children == null) {
          children = new ArrayList&lt;Node&gt;();
      }
      children.add(child);
  }
  
  public MyNode getData() {
      return this.data;
  }
  
  public void setData(MyNode data) {
      this.data = data;
  }
  </code></pre>
  
  <p>and for Mynode I have : </p>
  
  <pre><code>public class MyNode {
  
  public String ID = new String();   //UUID
  protected String parentID;
  MyNodesDATA d = new MyNodesDATA();
  
  
  public MyNode() {
      setID(UUID.randomUUID().toString());
  }
  
  public MyNodesDATA getMyNodesDATA () {
      return this.MyNodesDATA ;
  }
  
  public void setData(MyNodesDATA d) {
      this.MyNodesDATA = data;
  }
  </code></pre>
  
  <p>and this is MyNodesDATA </p>
  
  <pre><code>public class MyNodesDATA {
  int iD;
  String name;
  }
  </code></pre>
  
  <p>So each node of the tree has an object of MyNode Type and each MyNode Object has a data as an object from MyNodesDATA class. I have already initialised the tree with a predefined structures of hierarchical nodes using some recursive methods which I didn't put here ... 
  Now, nodes of the tree in lover levels process their data and need to send them to their parents (USING THEIR PARENT ID). I stuck here... how a node (an object) can send it's data to another node (another object) (let say its parent in this scenario) using only one ID variable of the other object ... in a simpler way I need a method to get (ID and DATA) and send the data to the object which has the ID !! and of course there should be another function or event handler in receiver side to take action once receives a Data .... </p>