This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Applets and the fly likes no suitable method found for replace(char,String) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "no suitable method found for replace(char,String)" Watch "no suitable method found for replace(char,String)" New topic
Author

no suitable method found for replace(char,String)

Hayles Berry
Ranch Hand

Joined: Dec 16, 2012
Posts: 32
Hello.


I am attempting to write a simple program, that determines whether the char variable 'sl1' (currently set to 'H' in my program) is in the string variable 'pr_word' (input by the user via a textfield) and, if so, removes that character from the string when the string is output. It also replaces that character with a polygon.

However, at the moment I'm getting the error "no suitable method found for replace(char,String)" and I'm not sure why.


This is the fragment of code that does what I mentioned above: ^



Any help/guidance will be greatly appreciated.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41063
    
  43
That means that there is no method with this signature: String.replace(char, String). If you look at the javadocs of the String class you can verify that. You'll need to use some other method that lets you remove or replace characters in a String object.


Ping & DNS - my free Android networking tools app
Hayles Berry
Ranch Hand

Joined: Dec 16, 2012
Posts: 32
Ulf Dittmer wrote:That means that there is no method with this signature: String.replace(char, String). If you look at the javadocs of the String class you can verify that. You'll need to use some other method that lets you remove or replace characters in a String object.


Thank-You, I've found what I was looking for now.
 
Consider Paul's rocket mass heater.
 
subject: no suitable method found for replace(char,String)
 
Similar Threads
Caesar cipher
How do I use a static method from another class?
force users to use english character set
String Replacement problem
Parsing and Insert