Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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)); //will print "abc"
}
Source by pages.cs.wisc.edu #
 
PREVIOUS NEXT
Tagged: #java #recursion
ADD COMMENT
Topic
Name
1+9 =