0

whats the problem?

(the code supposed to make multible question marks into one, also with exclamation marks...) code: import java.util.*; public class Main { public static void main(String[] args) { String yell = "no???"; if (yell.contains ("!")){ yell = yell.replaceAll("!" , ""); yell = yell.concat("!"); System.out.println(yell); }else if (yell.contains ("?")){ yell = yell.replaceAll("?" , ""); yell = yell.concat("?"); System.out.println(yell); }else{ return; } } }

15th Aug 2020, 4:03 PM
Yahel
Yahel - avatar
1 Réponse
+ 3
main() is void so it cannot return anything. Remove the last else part. Also you need to escape the '?' character, so in replaceAll() instead of using just "?" make it "\\?" and it should work properly. https://stackoverflow.com/questions/4554749/replace-a-question-mark-with
15th Aug 2020, 4:34 PM
Avinesh
Avinesh - avatar