java replace

replace() StringBuffer Example

replace() StringBuffer Method java.lang.StringBuffer class comes with many methods to manipulate string. replace() method replaces a group of characters in the buffer. What Java API says about replace() StringBuffer: public synchronized java.lang.StringBuffer replace(int startIndex, int endIndex, String string1): Replaces a group of characters of string buffer from startIndex to endIndex-1 with string string1. Replaced number …

replace() StringBuffer Example Read More »

replace() String Example

java.lang.String class comes with replace() String method to replace existing characters in a sting with new characters. The signature of replace() String as given in Java API. public String replace(char oldChar, char newChar): Returns a new string after replacing characters. All the occurrences of oldChar in the string are replaced by newChar. In the following …

replace() String Example Read More »