Java program to check Palindrome

Last updated on March 14th, 2017 at 01:53 pm

Previous
Next
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.

Previous
Next

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.

Add Comment

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.
You can like our facebook page Java2blog