Answers for "Write a Java program to check whether given string is palindrome or not (Use StringBuffer object and reverse() method)."

1

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(str + " string is palindrome.");
      }
      else
      {
         System.out.println(str + " string is not palindrome.");
      }
   }
}
Posted by: Guest on February-22-2021

Code answers related to "Write a Java program to check whether given string is palindrome or not (Use StringBuffer object and reverse() method)."

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language