Program to check for palindrome string in java

class Palindrome
public static void main(String args[])
String original, reverse=””;
//reading arguments from command-line.
original = args[0];
//returns lenght of the string
int length = original.length();
for ( int i = length – 1 ; i >= 0 ; i– )
reverse = reverse + original.charAt(i);
//checking match between original string and reverse //string
if (original.equals(reverse))
System.out.println(“Entered string is a palindrome.”);
System.out.println(“Entered string is not a palindrome.”);
Compiling and running program:
>java Palindrome JAVA
Output :
Entered string is not a palindrome.

Leave a Reply

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