public class RemoveCharacter {
static char ch = 'e';
public static void main(String args[]) {
String str= "seuesheile";
System.out.println(removeCharacter(str));
}
static String removeCharacter(String str){
int index = str.indexOf(ch);
if(index==-1) {
return str;
}
return removeCharacter(str.substring(0, index)+str.substring(index+1,str.length()));
}
}
output: sushil
No comments:
Post a Comment