Link to home
Start Free TrialLog in
Avatar of mr_kirbs
mr_kirbs

asked on

Removing spaces from a Java string

I have a simple java program reading a name of type string from the database.
If the string contains 2 spaces between the first name and the second name I want to remove one of these spaces. Example if the database contains the name David  Jones (2 spaces between David and Jones) I want to return David Jones(only 1 spaces between David and Jones).

Seems simple but confusing me none the less??
Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mr_kirbs
mr_kirbs

ASKER

What I used:

.replaceAll("  ", " ");

Cheers