• Post Reply Bookmark Topic Watch Topic
  • New Topic

Replace method in strings  RSS feed

 
Ranch Hand
Posts: 234
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, I can't quite qork out because this snippet doesn't compile:

I'm trying to replace characters of a string with a new string but I get this in my compiles:

Am I getting the method signature wrong?
 
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The String class does not have a replace() method with that signature. Perhaps you are confusing it with the replace() method of the StringBuffer/StringBuilder class?

Henry
 
Jason Attin
Ranch Hand
Posts: 234
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I think you're right, if I run the same method on a StringBuilder it works, thanks for clarifying it
 
Marshal
Posts: 56605
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might be easier to understand if you use StringBuilder explicitly:-StringBuilder doesn't appear to have a replaceAll method.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!