Sometime’s we need to change some part of the string with other string then we can do this by using a method called string replace which does the work of replace the string with what we want to be replaced.
String android = "Welcome to AndroidCoding.in";
android = string.replace(" ", "-");
Then here empty space will be replaced by ‘-‘
Output will be
And also when ever you want to send any variable which may contains spaces in between through php(sometimes) theb the value after the space may be eliminated so to avoid the elimination of text agter space use
android = string.replace(" ", "%20");
now value is never eliminated even though there is a space break between words.