- yes or no?
- Yes or No!
- No E Allowed
- Repetition
- PigLatin I
- Pig Latin II
- Pig Latin III
- Pig Latin Finale
Java String Resources:
No E Allowed
Collapse Content
Show Content
The Kingdom of Zumbania decided to ban the letter 'e'. Create a method that replaces every 'e' in a String with an 'a'.
Note: Capital E's should be replaced with Capital A's.
Challenge
Replace every 'e' with an 'a' and return the 'sanitized' String.
Please sign in or sign up to submit answers.
Alternatively, you can try out Learneroo before signing up.
Comments
David
Jun 5, 4:37 PMHints, please. Or someone from outside that might post a possible solution
Learneroo
Jun 5, 10:15 PM@David, search for 'replace' on the Learneroo or Oracle Java reference (linked to on sidebar).
David
Jun 6, 8:30 PMI understand that String are not mutable. However i can not manage to print "Avarything Has Changad" as a single word, instead it is done as 3 different words...
David
Jun 6, 8:56 PMI have tried with replace previously and had the exact same issue where it prints:
Avarything
Has
Changad
Instead of:
Avarything Has Changad
As per the correct output.
So my point is i have been able to do the changes accordingly through several ways, the problem is that its always returned as three different strings rather than a unique one.
David
Jun 8, 1:15 PMLook, even if i return just 'word' without doing any modification, the "Everything Has Changed" is still cut off:
Correct Output
alaphant
Angland
string
Avarything Has Changad
oranga
aal
Your Output
elephant
England
string
Everything
Has
Changed
Learneroo
Jun 8, 1:31 PM@David, sorry about that, it's fixed.
David
Jun 8, 1:35 PMThanks Admin :) I was becoming quite insane hehe.
thales
Jul 17, 7:55 AMa solution:
my code
Cliff Karlsson
Aug 5, 4:21 AMquick and dirty solution would be :
return text.replace(a,b).replace(A,B)