Hi Pagano,
According to the
Java SE8 documentation for replace(), the second int argument refers to "the ending index, exclusive"
Also note that according to the same reference, "First the characters in the substring are removed and then the specified String is inserted at start."
My interpretation is that the second int argument represents the index position (in the original sequence), from which no further characters are deleted during the replace operation.
Basically, it will specify how many characters need to be removed from the original sequence before we start inserting the new String.
Some examples may make it more clearer (Disclaimer : I haven't tested these locally)
From the above examples, we see that the end index was needed to specify how many characters needed to be removed from the original StringBuilder sequence.
Hope this helps
Thanks,
Shantanu Bhate.