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:


Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs