RE: Java Replacing characters

  • From: "Sina Bahram" <sbahram@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 28 Jul 2010 21:01:36 -0400

Strings are imuteable. If you proceed with this understanding, then use the 
series of functions that simply result in the new string
containing what you want.

String old = "Hello World";
String new = "Goodbye "+old.substring(blah, blah);

Etc, etc


Does that make sense?

Take care,
Sina

________________________________

From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Gilbert Neiva
Sent: Wednesday, July 28, 2010 7:13 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Java Replacing characters


How do I replace a character in a string varriable with another.
 
string word1;
word1 = "cot"
 
How would I for example replace the o with an a. I know that the method 
charAt() can be used to extract a character from a group of
characters within a string. I know that subString method can be used to extract 
a parcial string from a string varriable. I also
know that indexOf method can be used to find a character or group of characters 
within a string varriable. I am not sure how to
insert, or even replace a character or group of characters within a string 
varriable. Can someone help me with this issue? Thanks.
 
Gilbert Neiva

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: