DEV Community

Rajesh Mishra
Rajesh Mishra

Posted on • Originally published at onlinetutorials.tech on

1

Palindrome Program in Java for Reversing String


Palindrome is nothing but any number or a string which remains unchanged when it is reversed. For example: 121 or RAR. It is observable that letters form reflect images on turn around.

class PalindromeProgramInJavaForReversingString{
      public static void checkPalindrome(String s){
      // Reversing given string using StringBuffer class
      String reverse = new StringBuffer(s).reverse().toString();

      // checks whether the string is palindrome or not
      if (s.equals(reverse)){
          System.out.println("Yes, it is a palindrome");
       }else{
          System.out.println("No, it is not a palindrome");
       }
     }
     public static void main (String[] args)throws java.lang.Exception{
        checkPalindrome("madam");
     }
 }

Learn More about Palindrome:


Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)