programs using recursion in java code example
Example 1: java recursion
public static void recursion(int x) {
if(x == 0) {
System.out.println();
} else {
System.out.print("$");
recursion(x - 1);
}
}
Example 2: java recursion
public void removeDigits(String string) {
if(string.length == 1) {
if(Character.isDigit(string.CharAt(0))) {
return "";
} else {
return string;
}
} else {
if(Character.isDigit(string.CharAt(0))) {
return removeDigits(string.substring(1));
} else {
return string.substring(0, 1) + removeDigits(string.substring(1));
public static void main(String[] args) {
String string = "1a2b3c"
System.out.println(removeDigits(string));
}