/**
* Checks if given <code>text</code> is a palindrome.
*
* @param text any string
* @return <code>true</code> when <code>text</code> is a palindrome, <code>false</code> otherwise
*/
public static boolean isPalindrome(String text) {
String tmp = text.toLowerCase().replaceAll("[^a-zа-я0-9]", "");
StringBuilder t = new StringBuilder(tmp).reverse();
return tmp.equals(t.toString());
}
* Checks if given <code>text</code> is a palindrome.
*
* @param text any string
* @return <code>true</code> when <code>text</code> is a palindrome, <code>false</code> otherwise
*/
public static boolean isPalindrome(String text) {
String tmp = text.toLowerCase().replaceAll("[^a-zа-я0-9]", "");
StringBuilder t = new StringBuilder(tmp).reverse();
return tmp.equals(t.toString());
}
Немає коментарів:
Дописати коментар