I would like an object to be comparable (to use it in a TreeSet in that case).
My object got a name field and I would like it to be sorted by alphabetical order.
You are overthinking the problem. Strings have their own natural ordering, which is alphabetic, so you can just use the String.compareTo like this:
String
String.compareTo
@Override public int compareTo(MyObject otherObject) { return this.name.compareTo(otherObject.name); }