public String replaceVowels(String s){
String replacement = "";
for(int i = 0; i <s.length(); i++){
if(s.charAt(i)=='a' || s.charAt(i)=='A' ||
s.charAt(i)=='e' || s.charAt(i)=='E'||
s.charAt(i)=='i' || s.charAt(i)=='I'||
s.charAt(i)=='o' || s.charAt(i)=='O'||
s.charAt(i)=='u' || s.charAt(i)=='U'){
replacement = replacement + '*';
}else{
replacement = replacement + s.charAt(i);
}
}
return replacement;
}
I want the code to replace vowels by * in the string and here is my test code
@Test public void tests8(){
code.Solution s = new code.Solution();
String input = "book ";
String expected = "b**k";
String actual = s.replaceVowels(input);
assertTrue("Expected was" +expected+"but the actual was" +actual , expected == actual);
}
The error is so weird when I run the junit it said that
expected was b * * k but the actual was b * * k
Whats wrong with my code?