str = str.replaceAll(" ", " "); // replace all double spaces with single Space
return str.trim(); // remove all LEFT side & Right Side Extra white spaces from the string
}
Bro, in the above code you can make a change by not using while. Because that will remove the spaces between the words also. Right? So only trim is ok.
2 comments:
Bro, in the above code you can make a change by not using while. Because that will remove the spaces between the words also. Right? So only trim is ok.
thanks buddy. i know we have to remove while statement.
str = str.replaceAll(" "," ");
use to remove duplicate spaces from the string.
this is just a example.
go through other posts
Post a Comment