Whats wrong with my code ?! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Whats wrong with my code ?!

import java.util.Scanner; public class Program{ public static void main(String [] args){ Scanner sc = new Scanner(System.in); String str = sc.nextLine(); str = str.replace('x', '\u0000'); if(str.contains("$T")==true || str.contains("T

quot;)==true){ System.out.println("ALARM"); } else{ System.out.println("quiet"); } sc.close(); } } The question is from CodeCoach Security problem

22nd Dec 2021, 6:18 AM
I.K.I.A.T.L
1 Answer
+ 1
Congratulations, nice idea 👍 Try it this way: str = str.replace("x", ""); This \u0000 will only not be printed, but is still there and will be considered as contained in the string.
22nd Dec 2021, 9:32 PM
Coding Cat
Coding Cat - avatar