Java program to check Palindrome

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.

Add Comment