import java.sql.SQLOutput;
public class removeX {
//write a java program to remove x from string using Recursion
public static String removeX(String str){
if(str.length() == 0){
return str;
}
String ans = "";
if (str.charAt(0) != 'x') {
ans = ans + str.charAt(0);
}
String smallans = removeX(str.substring(1));
return ans + smallans;
}
public static void main(String[] args) {
System.out.println(removeX("absxsnd"));
}
}
Comments
Post a Comment