DEV Community

Rajesh Mishra
Rajesh Mishra

Posted on • Originally published at on


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");
          System.out.println("No, it is not a palindrome");
     public static void main (String[] args)throws java.lang.Exception{

Learn More about Palindrome:

Oldest comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.