i want the sentence without numbers. But what's wrong here? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

i want the sentence without numbers. But what's wrong here?

https://code.sololearn.com/cGppQA31k8OF/?ref=app

10th May 2020, 11:47 AM
Harithra Shanmugam
1 Answer
+ 1
a=s.replaceAll("1","one"); a=s.replaceAll("2","two") Here, you are storing new string in a, which is 1 replaced, next replacing 2 but not in new string a but in old string s.. So only last 9 is replaced result will be available by overwriting old once... So do like this... a=s.replaceAll("1","one"); a=a.replaceAll("2","two");..... Without needing a variable, use only s like.. s=s.replaceAll("1","one"); s=s.replaceAll("2","two"); ... s=s.replaceAll("9","nine);
10th May 2020, 3:54 PM
Jayakrishna 🇮🇳