String palindrome in java using stringbuffer code example
Example: String palindrome in java using stringbuffer
// String palindrome in java using stringbuffer
public class PalindromeUsingStringBuffer
{
public static void main(String[] args)
{
String strInput = "nayan";
StringBuffer sb = new StringBuffer(strInput);
sb.reverse();
String str = sb.toString();
if(strInput.equals(str))
{
System.out.println("string is palindrome.");
}
else
{
System.out.println("string is not palindrome.");
}
}
}