This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes replacing blank space Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "replacing blank space" Watch "replacing blank space" New topic

replacing blank space

kevin schmidt
Ranch Hand

Joined: Aug 24, 2001
Posts: 85
I have a program that raeds in words, either one or two words. Now, If the program reads in two words, there is a space separating the words. How do I replace the space with and underscore?
before - Meeting Organizer
after - Meeting_Organizer
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
after = before.replace(' ', '_');
I agree. Here's the link:
subject: replacing blank space
It's not a secret anymore!