I am making a program where i have to write a recursive function that reverses a string. I am a new programmer and need help. The function should return a String and take only one argument, also a String.
import java.io.*;
public class RecursiveFunction {
public static void main(String [] argv) throws IOException
{
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in), 1);
System.out.println("Enter a string that you would like to reverse");
String userInput = stdin.readLine();
}
static String reverse(String userInput)
{
//what do i write here
return userInput;
}
}
I don't know how to reverse the string or how to call the function from main().