Skip to content

Instantly share code, notes, and snippets.

@10851077
Created October 5, 2010 06:42
Show Gist options
  • Save 10851077/611133 to your computer and use it in GitHub Desktop.
Save 10851077/611133 to your computer and use it in GitHub Desktop.
public static boolean esPalindromo(String X){
boolean palindromo;
String Y = "";
String X2 = X.trim();
for (int i =X2.length()-1;i>=0;i--)
Y = Y + X2.charAt(i);
if(Y.equalsIgnoreCase(X2))
palindromo = true;
else
palindromo = false;
//System.out.println("X "+X);
//System.out.println("Y "+Y);
return palindromo;
}
public static void main(String[] args) {
Scanner entrada = new Scanner(System.in);
String Palabra;
System.out.println("Ingrese una cadena de caracteres: ");
Palabra = entrada.nextLine();
System.out.println(esPalindromo(Palabra));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment