Created
January 14, 2013 23:05
-
-
Save RicardoMurad/4534387 to your computer and use it in GitHub Desktop.
Verifica se uma string é palindroma
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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