title: Get java object by id
body: <p>What I am trying to achieve is to update an object's value with only his ID known:</p>
  <ol>
  <li>How can I get the object with a corresponding ID?</li>
  <li>So that I can update a property?</li>
  </ol>
  <p><strong>class forest</strong></p>
  <pre><code>public class forest {
      public forestName;
      
      public forest(String forestName){
          this.forestName=forestName;
      }
      updateTreeName(int id, String Name){
          // Here I need to update the name of the tree with that specific ID
      }
  
      public static void main(String[] args) {
          forest greenforest = new forest();
          // create some tree's in the greenforest.
          greenforest.updateTreeName(4, &quot;red leafe&quot;);
      }
  }
  </code></pre>
  <p><strong>class tree</strong></p>
  <pre><code>public class tree {
      public String treeName;
      public int id;
      public tree(int id, String treeName){
          this.treeName=treeName;
          this.id=id;
      }
  }
  </code></pre>