Class RecursiveHelper
public class RecursiveHelper
extends java.lang.Object
Constructor Summary
All Methods
boolean palindromeChecker(java.lang.String str)
int powerOf(int x, int y)
java.lang.String reverseString(java.lang.String str)
Class Overview
public class RecursiveHelper{
Advanced Usage
public java.lang.String reverseString(java.lang.String str)
This recursive method takes one parameter, a String. You can probably imagine what it does, it just reverses the String. So if we provided "Hello", the return value would be "olleH". Remember for each of these recursive methods, you will need to call the method in itself, and establish a base and recursive case. For this specific method, you may want to use the String.substring() method.
Parameters:
str - Current value of String
Returns:
reverse String
public int powerOf(int x, int y)
{
int result = 1;
for(int i = 0; i < y; i++){
result = result * x;
}
return result;
}
public boolean palindromeChecker(java.lang.String str)
{
String strToCheck = str;
This recursive method takes a String parameter and checks whether the provided String was a palindrome. Depending upon whether the String was a palindrome return true or false. For example, "level" would return true, "sponge" would not. The String.charAt and substring methods may help you in this method!
return true or false;
}