public static boolean isPalindrome(String s)Note: This is declared
static
because it is doesn't depend on
instance variables from the class it would be defined in.
It only depends on its parameters.
It's declared public
only because
it might be generally useful.
Call | Returns | Comments |
---|---|---|
isPalindrome("Hello") | false | Not a palindrome. |
isPalindrome("radar") | true | Is a palindrome. |
isPalindrome("Able was I ere I saw elba.") | true | Is a palindrome. |
isPalindrome("A man, a plan, a canal -- Panama!") | false | Not a palindrome by our definition. See extensions. |