isPalindrome Demo
Live JS — Step-Through Demo
// Java — What does this return? public static boolean isPalindrome(String s) { if (s.length() <= 1) { return true; } else if (s.charAt(0) != s.charAt(s.length() - 1)) { return false; } else { return isPalindrome(s.substring(1, s.length() - 1)); } }//end isPalindrome
String s = "";
boolean r = isPalindrome(s);
| Call: | Recursive Call: | Return Statement | Result: |
|---|