0

Need help here.

How do you remove the duplicate result showing from the output?? here is my code : System.out.println("Enter letters only"); String alpha = scan.nextLine(); String numb = "[0-9]"; if(alpha.matches("[a-zA-Z]")) { System.out.println(alpha); }else System.out.println(alpha.replaceAll(numb , " not a letter")); } } INPUT qwerty123 OUTPUT qwerty not a letter not a letter not a letter I want it to be ( qwerty not a letter ).

3rd Apr 2020, 10:23 AM
Zeyah
Zeyah - avatar
4 Respostas
+ 3
Zeyah Why you don't write like this. System.out.println(alpha.replaceAll(numb, "") + " not a letter");
3rd Apr 2020, 10:34 AM
A͢J
A͢J - avatar
0
intenta con replace(numb,"not a letter")
3rd Apr 2020, 10:33 AM
Marco
Marco - avatar
0
thank you very much for your help 😄
3rd Apr 2020, 10:45 AM
Zeyah
Zeyah - avatar
0
ooops the (not a letter) is showing even I input alphabets only but thanks thoo😂
3rd Apr 2020, 10:50 AM
Zeyah
Zeyah - avatar