Palindrome using StringBuffer
This is my program:
public class Palindrome
{
public static void main(String[] args)
{
String str1= new String("malayalam");
StringBuffer str2= new StringBuffer(str1);
StringBuffer str3= new StringBuffer(str1);
str2.reverse();
System.out.println("First String:"+str2+ "Length:"+str2.length());
System.out.println("Second String:"+str3+ "Length:"+str3.length());
if (str2.equals(str3))
System.out.println("Was a palindrome");
else
System.out.println("Was not a palindrome");
}
}
The output I'm getting is:
First String:malayalamLength:9
Second String:malayalamLength:9
Was not a palindrome
Where is the problem?

