title: Implements Comparable to get alphabetical sort with Strings
body: <p>I would like an object to be comparable (to use it in a TreeSet in that case).</p>
  
  <p>My object got a name field and I would like it to be sorted by alphabetical order.</p>
  
  <p>I thought first that I could use the unicode value of the string and simply do a subtraction, but then AA would be after Ab for example…</p>
  
  <p>Here’s how I started :</p>
  
  <pre><code>public final class MyObject implements Comparable&lt;MyObject&gt; {
  
   private String name;
  
   public MyObject(String name) {
    this.name = name;
   }
  
   public String name() {
    return name;
   }
  
   @Override
   public int compareTo(MyObject otherObject) {
    return WHAT DO I PUT HERE ?;
   }
  }
  </code></pre>
  
  <p>Thanks to those who will help,
  have a nice day!</p>