String str = "A BE LINCOLN";
str = "GEOR GE W";
There are 2 spaces between A and BE.
There are more than 2 spaces between GEOR and GE
results should be
str = "ABE LINCOLN";
str = "GEORGE W";
How do you remove spaces if spaces > 1
If I did a count for spaces, how do you use result of count to replace? Or is there an easier way to do this? Thank you very much.
int count = 0;
for (int i = 0; i < str.length(); i++)
{
if (str.charAt(i) == ' ')
{
count++;
}
}
str = str.replaceAll(???, " ");