0
Help me to understand this program
7 odpowiedzi
+ 2
zahraa 🇱🇧 you're welcome..
And thanks for understanding... 👍👍👍
+ 2
Jayakrishna🇮🇳 you're right, I'm sorry. I got mixed up. Thanks for your attention 🌸
Sindhuja Selvakumar I was mistaken, I edited my comment.
+ 1
System.out.println(a.replaceAll("[0:9]",("")));
The 1st argument, is a regex of a class of consisting 3 charecters '0',':','9'. And these 3 are replaced by "" empty charecter in a new formed string.
+ 1
String a="java99s155";:
this statement assigns the value "java99s155" to the variable a (which of type string)
System.out.println(a.replaceAll("[0:9]",(""))):
this statement search for all occurences of the characters ('0',':','9') in string a ([0:9] can be translated as the three characters '0',':','9') and replace those characters by empty strings ( "" means empty string)
As a conclusion, this program prints a string which is "the string a converted to a string free of characters '0',':', and '9'."
+ 1
Wow super explanation tq soo much the program was clear now
+ 1
Anytime 🌸
+ 1
I want to add,
"[0:9]" - Not Replace all the numbers.. Just 3 charecters.
Check the output..
To replaceall numbers,you need to use "[0-9]".