Java program to print whether the given string is a palindrome



A given string is called a palindrome if the reverse of the string is the string itself. For example, the strings “mom”, “bob”.

Algorithm

1. Get the number to check for palindrome
2. Hold the number in a temporary variable
3. Reverse the number
4. Compare the temporary number with the reversed number
5. If both numbers are same, print "palindrome number"
6. Else print "not palindrome number"

Program

But if we want to check if "Madam" is palindrome or not , it will show us that it is not a palindrome because of the upper case of first letter.


Advertisements