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.
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.
ReplyDeletethanks buddy. i know we have to remove while statement.
ReplyDeletestr = str.replaceAll(" "," ");
use to remove duplicate spaces from the string.
this is just a example.
go through other posts