This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Is it possible to remove all spaces from a String?(SOLVED) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Is it possible to remove all spaces from a String?(SOLVED)" Watch "Is it possible to remove all spaces from a String?(SOLVED)" New topic
Author

Is it possible to remove all spaces from a String?(SOLVED)

Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

No matter how many there are.

One Space should become OneSpace
Two More Spaces should become TwoMoreSpaces
etc


solution




-thanks henry


True wisdom is in knowing you know nothing - Socrates
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16695
    
  19

Sure... Take a look at the java.lang.String replace(), or replaceAll() methods.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16695
    
  19

Matt Kohanek wrote:
solution




Interesting solution. How about something much simpler? Like....



Henry
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

lol, well it just wouldnt feel like my code unless it was overly complicated and inefficient!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Is it possible to remove all spaces from a String?(SOLVED)
 
Similar Threads
exercise getServiceByName
how to print in capital of each frist word
Determine the space occurrence within a String
how to string search ?
how to reverse words in line