Code correction suggestion using Java libraries for strings?
<p>I know there is an easier way of making things work to check whether a string is a palindrome or not, but I wanted to try it using library functions and I came up with the code below. </p>

<pre><code>public boolean isPalindrome1(String input)
{

    int length = input.length()/2;
    if(input.length()%2!=0)
    {
        length = length + 1;
    }


    return(input.substring(0,length).equals(new StringBuilder(input.substring(length, input.length())).reverse().toString()));
}
</code></pre>

<p>I'm trying to check whether half the string is equal to the other half's reverse. But it is getting messed up for odd and even lengths. Can someone point corrections in this where it will work for odd, even lengths as well as empty string and string of length = 1. </p>
