Question:
String – Replace Characters
Write a recursive function ‘public static String replace(String str,char from,char to) ‘ that changes all occurrences of ‘from’ in ‘str’ to ‘to’.
For example, if str were “codebook”, and from = ‘o’ and to = ‘e’, then, str would become “cedebeek”.
Function Definitions:
public static String replace(String str, char from, char to)
Problem Requirements:
Keyword | Min Count | Max Count |
for | 0 | 0 |
while | 0 | 0 |
Note: Create the main() inside the class ‘ReplaceDriver’
Refer sample input and output for formatting specifications.
Sample Input and Output :
Enter the string
Asia
Enter the character to be replaced
a
Enter the character to be replaced with
i
The modified string is Asii
CODE:–
ReplaceDriver.java
Tags:
binary tree | linear data structure | data structures in c | data structure | heap sort | abdul bari udemy
data structures udemy | coding ninjas data structures | binary tree example | data structure and algorithmic thinking with python | queue geeksforgeeks | data structures in c programming
ConversionConversion EmoticonEmoticon