Skip to content

Instantly share code, notes, and snippets.

@ellbur
Created October 23, 2011 08:05
Show Gist options
  • Save ellbur/1307035 to your computer and use it in GitHub Desktop.
Save ellbur/1307035 to your computer and use it in GitHub Desktop.
Palindrome puzzle
public class Pal {
public static void main(String[] args) {
String word = "Racecar";
word = word.toLowerCase();
boolean ok = true;
for (int n=0; n<=word.length()-1; n++) {
if (word.charAt(n) == word.charAt(word.length() - n - 1)) {
}
else {
ok = false;
break;
}
}
if (ok) {
System.out.println("Yes");
}
else {
System.out.println("No");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment