title: What is the best way to find a object inside TreeSet based on internal field?
body: <p>I have the following object in a <code>TreeSet&lt;MyObject&gt;</code>:</p>
  
  <pre><code>public class MyObject implements Comparable&lt;MyObject&gt; {
      private Long id;
      private String Name;
  
      public void setId(Long id) {
          this.id = id;
      }
  }
  </code></pre>
  
  <p>I would like to search if an element of <code>id = 5</code> exists in this <code>TreeSet</code>. How can I do this?</p>