import java.io.*;
public class Problem1
{
public static void main (String [] args) throws IOException
{
BufferedReader inKb = new BufferedReader (new InputStreamReader (System.in));
String word = inKb.readLine ().toLowerCase ();
char lettersRev [] = new char [word.length ()];
for (int i = 0, n = word.length () -1 ; i < word.length () ; n--, i++)
{
lettersRev [i] = word.charAt (n);
}
String wordRev = new String (lettersRev);
System.out.println (word + " Reversed: " + wordRev);
if (wordRev == word)
{
System.out.println (" Is a Palindrome! " );
}
} // main method
}
As far as I can see, this should work?
E.G: racecar reversed == racecar therefore it is a palindrome
Any ideas.
Thanks, v0rtex
This post has been edited by v0rtex: 24 August 2010 - 11:29 AM

New Topic/Question
Reply




MultiQuote







|