Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

no suitable method found for replace(char,String)

 
Hayles Berry
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Hayles Berry
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic