title: How do I compare Strings in Java without using compareTo?
body: <p>I need to compare two Objects by a string attribute, how can I do this without using the compareTo() method?</p>
  
  <p>My code looks something like this :</p>
  
  <pre><code>public int compareTo(className b){
  if (b instanceof className){
          className a = (ClassName ) b;
      if (this.stringName==a.stringName) return 0;   
      if (this.stringName &gt; a.stringName) return 1;   // &lt;- How can I know if it this bigger or smaller? Can't use &lt; &gt; operators on strings.
         else 
              return -1;
  }
  </code></pre>