[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/debugmm/Java/master/strings/Palindrome.java [Back]  [Original]

package strings;

/** Wikipedia: https://en.wikipedia.org/wiki/Palindrome */
class Palindrome {

  /** Driver Code */
  public static void main(String[] args) {
    String[] palindromes = {null, "", "aba", "123321"};
    for (String s : palindromes) {
      assert isPalindrome(s) && isPalindromeRecursion(s) && isPalindrome1(s);
    }

    String[] notPalindromes = {"abb", "abc", "abc123"};
    for (String s : notPalindromes) {
      assert !isPalindrome(s) && !isPalindromeRecursion(s) && !isPalindrome1(s);
    }
  }

  /**
   * Check if a string is palindrome string or not
   *
   * @param s a string to check
   * @return {@code true} if given string is palindrome, otherwise {@code false}
   */
  public static boolean isPalindrome(String s) {
    return (s == null || s.length() 

Web Proxy Viewer  |  New URL  |  Original Page