This is somehow a duplicate of this problem Ruby - replace the first occurrence of a substring with another string just in java.
Problem is:
I have a string:
Try the replaceFirst method. It uses a regular expression, but the literal sequence "ha" still works.
"ha"
string.replaceFirst("ha", "gurp");