File tree 1 file changed +3
-4
lines changed
1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -15,17 +15,16 @@ public static void main(String[] args) {
15
15
recursiveStringReplace (ans , part );
16
16
17
17
// Display the result.
18
- System .out .println ("The final string after removing all the occurrences of a substring: " + ans + "." );
18
+ System .out .println ("The final string after removing all the occurrences of a substring: " + ans + "." );
19
19
}
20
20
21
21
// Recursive call the function itself to replace the string with the part.
22
- private static StringBuilder recursiveStringReplace (StringBuilder s , String part ) {
22
+ private static void recursiveStringReplace (StringBuilder s , String part ) {
23
23
for (int i = 0 ; i <= s .length () - part .length (); i ++) {
24
24
if (s .substring (i , i + part .length ()).equals (part )) {
25
- s = s .delete (i , i + part .length ());
25
+ s .delete (i , i + part .length ());
26
26
recursiveStringReplace (s , part );
27
27
}
28
28
}
29
- return s ;
30
29
}
31
30
}
You can’t perform that action at this time.
0 commit comments