This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Getting MEAN with Mongo, Express, Angular, and Node and have Simon Holmes on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes String.replace to remove a character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String.replace to remove a character" Watch "String.replace to remove a character" New topic
Author

String.replace to remove a character

Ronnie Phelps
Ranch Hand

Joined: Mar 12, 2001
Posts: 329
I know you can use String.replace to replace a character with a space but can you use this same method to remove the character?
I.E
-----------
String st = "I'm";
st = st.replace('\'','some character I dont know about');
System.out.println(st);
-------------
would print Im
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
sorry but i don't know if a empty char exist!
if you have to do this use a little loop like this:

------------------
Benjamin l´┐Żonard
www.evisor.com
Ronnie Phelps
Ranch Hand

Joined: Mar 12, 2001
Posts: 329
Cool. THANKS.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: String.replace to remove a character