Skip to content

Instantly share code, notes, and snippets.

@yekmer
Created January 25, 2014 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yekmer/8624073 to your computer and use it in GitHub Desktop.
Save yekmer/8624073 to your computer and use it in GitHub Desktop.
Check if a string is palindrome?
public class Palindrome {
public static void main(String[] args) {
String st = "abcecba";
System.out.println(isPalindrome(st));
}
public static boolean isPalindrome(String st) {
for(int i = 0; i < st.length() - i - 1; i++) {
if(st.charAt(i) != st.charAt(st.length() - 1 - i)) {
return false;
}
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment