understanding compareto() method in java <p>i came across a MIT lecture on recursion where they checked palindrome using recursion,and there they checked it using logic where they compare first and last alphabet and so on.. what i thought is something as follows</p> <p>just a pseudo code:</p> <pre><code> String original="abba"; String reverse = ""; for(int i=original.length()-1;i&gt;=0;i--) { reverse+=new String(original.substring(i,i+1)); } if(original.equals(reverse)) System.out.println("palindrome"); else System.out.println("not palindrome"); </code></pre> <p>i have two doubts </p> <ul> <li>Is this logic better than recursion or conventional logic in terms of time complexity?</li> <li>How does <code>compareTo()</code> method checks if strings are equal? DOes it compare bytecode or something?</li> </ul>