Wednesday, September 7, 2011

Java: replace chars in String

/*
        Replaces all occurrences of given character with new one
        and returns new String object.
*/

String returnString = "test string to do some change";
returnString = returnString.replace( 'o', 'd' );

Source:
http://www.javadeveloper.co.in/java-example/java-string-replace-example.html
http://javarevisited.blogspot.com/2011/12/java-string-replace-example-tutorial.html
References:
http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html

No comments: