This post originated from an RSS feed registered with Java Buzz
by Arpit Mandliya.
Original Post: Java String Replace
Feed Title: Java tutorial for beginners
Feed URL: http://feeds.feedburner.com/arpitmandliyasblog
Feed Description: A blog about java programming language and its frameworks
Java String replace method replaces all occurrences of old char to new char or old CharSequence to new CharSequence and return new String. If there is nothing to replace in the String, it will return same String. Let’s say you need to convert “Java2blog” to “JavaTwoblog”, you can simply use below syntax. Syntax There are two overloaded version of String’s replace method. Example Let’s understand with the help of Simple example. When you run above program, you will get below output: HelloWorld converted to : HellnWnrld Above program will call public String replace(char oldChar, char newChar) version