Skip to content

Instantly share code, notes, and snippets.

@RicardoMurad
Created January 14, 2013 23:05
Show Gist options
  • Select an option

  • Save RicardoMurad/4534387 to your computer and use it in GitHub Desktop.

Select an option

Save RicardoMurad/4534387 to your computer and use it in GitHub Desktop.
Verifica se uma string é palindroma
package com.foo.bar;
public class Palindromo {
public static void main(String[] args) {
String teste1 = "assimaalunaanulaamissa";
String teste2 = "qqcoisa";
System.out.println(isPalindromo(teste1));
System.out.println(isPalindromo(teste2));
}
public static boolean isPalindromo(String palavra) {
return new StringBuilder(palavra).reverse().toString().equals(palavra);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment