I'm going to find number chars in a String and replace them with their Roman versions. The Code is:
But at the end it prints the same string
. What is
wrong with my code?
This is not how you do a
gives you the matched part of the string. Whatever replacement you do in it,
you have to perform concatenation with original string. This is due to the fact
s are immutable
objects. You don't perform in-place replacement to it.
You do it like this: