appendReplacement and appendTail are the methods that do the real work when you call replaceAll. Each time a match is found in the input, appendReplacement appends to the output all the text between the previous match and the current one, then it appends the replacement text. appendReplacement is also the method that processes the replacement text, converting $1, $2, etc. to the corresponding captured groups. When there are no more matches, appendTail appends whatever's left of the input (whatever followed the last match).
You use appendReplacement and appendTail directly when you want to process the input in some other--or additional--manner than replaceAll does. For instance, if you want to use the matched text as a key to look up the replacement value in a table, you have to write your own replaceAll equivalent. Here's an example I happened to have handy:
To be blunt, this example is pretty bad. It is not only *NOT* "very very good", it is not even a valid example as it is being used wrong.
The appendReplacement() method is paired up with the appendTail() method. This example doesn't do that. And if you look at the output, you will see that it does more than just a simple replacement. It also truncates everything after the match (due to the missing appendTail() call). Unfortunately, it is only a period that has been truncated -- which probably went unnoticed.
Anyway, if this is a sign of the quality, I would highly recommend that you use a different site to learn Java.