Given this code :
String replaced = "A".replaceAll(".*", "HI");
Why does replaced
contain the string HIHI
instead of HI
as I would have guessed? It seems that it has something to do with the beginning of a line since using the pattern ^.*
yields HI
, but I don't get the reason for this.