my assignment question is like that
Write a program which prints the letters in a char array in reverse order using
void printReverse(char
This is a class which reveres the character array using recursion.
public class ReverseString {
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = new String("Hello");
char[] strcharArray = str.toCharArray();
printReverse(strcharArray);
}
private static void printReverse(char [] str) {
helper(0, str);
}
private static void helper(int index, char [] str) {
if (str == null || index >= str.length) {
return;
}
helper(index + 1, str);
System.out.println(str[index]);
}
}