Palindrome program in java

In this article, we will see how to implement palindrome program in java.

A palindrome is a word, phrase, number, or other sequence of symbols or elements that reads the same forward or reversed.

For example: 12121 is palindrome as it reads same forward or reversed. madam is also a palindrome .
This is very simple interview question.There are many ways to check if given string is palindrome or not.

Reversing a String and then comparing it with input String:

Run above program, you will get following output:

Using half loop,Moving from both end of String simultaneously:

Run above program, you will get following output:

Using StringBuilder’s reverse() function:

Run above program, you will get following output:
Please go through java interview programs for more such programs.

That’s all about palindrome program in java.

You can also check Python program to check if String is palindrome.


import_contacts

You may also like:

Related Posts

Leave a Reply

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

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.