PDA

Click to See Complete Forum and Search --> : [RESOLVED] String Replace...


wpearsall
Feb 5th, 2004, 07:00 PM
can somebody tell me what the error in this code is please?


// NOTE:
// client.sSpaceRep = "%20";

public String EncodeChatMsg(String ChatMsgIn){
String sReplace;
// Start the process of editing the message
sReplace = ChatMsgIn;
// Find any double spaces
while(sReplace.indexOf(" ") != -1){
// change the double to single space
sReplace.Replace(" "," ");
}
// replace single spaces with %20
sReplace.Replace(" ",client.sSpaceRep);
// Return the edited msg
return sReplace;
}


C:\Programming\TheWalks\TheWalksChat\JavaChat\chatclient\ClientInterface.java:253: cannot resolve symbol
symbol : method Replace (java.lang.String,java.lang.String)
location: class java.lang.String
sReplace.Replace(" "," ");
^
C:\Programming\TheWalks\TheWalksChat\JavaChat\chatclient\ClientInterface.java:255: cannot resolve symbol
symbol : method Replace (java.lang.String,java.lang.String)
location: class java.lang.String
sReplace.Replace(" ",client.sSpaceRep);
^

Dillinger4
Feb 6th, 2004, 12:23 AM
Taking a quick look at your code you should use replace() not Replace();