Check Given String Palindrome or Not in Java

In this post we’ll see how to write a Java program to check whether a given string is palindrome or not.

A string is said to be a palindrome if it remains same when reversed as example mom, malayalam.

Given String Palindrome or not – Java program

In order to find if a given string is palindrome or not in Java, you can use reverse() method of the StringBuider class to reverse the String and then compare it with original String. If both are same then the passed String is a palindrome.

If you are specifically asked not to use any inbuilt method in Java then you can build a reverse string by reading the passed string backward. In the below Java program solution using both of the above options is given.


That’s all for the topic Java Program to Check Given String Palindrome or Not. If something is missing or you have something to share about the topic please write a comment.

You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.