title: TreeSet_Getting the value of object instead of the expected instance variable value
body: <pre><code>    import java.util.TreeSet;
      
      public class TestTree {
          
          public static void main(String[] args) {
              
              new TestTree().go();
          }
          
          public void go() {
              
              Book b1 =  new Book(&quot;How cats Work&quot;);
              Book b2 =  new Book(&quot;Remiz your body&quot;);
              Book b3 =  new Book(&quot;Finding Emo&quot;);
              
              
              TreeSet&lt;Book&gt; tree = new TreeSet&lt;Book&gt;();
              tree.add(b1);
              tree.add(b2);
              tree.add(b3);
              
              System.out.println(tree);
                          
          }
      
      }
      
      class Book implements Comparable{
          
          String title;
          
          public Book(String t) {
              
              title = t;
          }
      
          @Override
          public int compareTo(Object o) {        
              Book book = (Book) o;
              return (title.compareTo(book.title));
          }
      }
  
  </code></pre>
  <p>Query</p>
  <blockquote>
  <p>Getting output as : [programs.Book@5a10411, programs.Book@2ef1e4fa, programs.Book@306a30c7]</p>
  <blockquote>
  <p>But need output : Finding Emo , How cats Work , Remiz your body</p>
  <blockquote>
  <p>Expected output should be title of the books been sorted. But while printing tree object getting the &gt;&gt;object values :( Could some one help to sort out what mistake i have done?
  I am new to collections and learning them, need some help friends.</p>
  </blockquote>
  </blockquote>
  </blockquote>