File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method overloading ???

 
juliane gross
Ranch Hand
Posts: 161
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am busy with Servlets-3 (Reverse2), and I am
almost(!) ready to send it in, but .... :
maybe I didn't understand something with method overloading?
I try to use a method from com.javaranch.common.* , which exists in 4 different variations, only distinguished by its kind of parameters
(char-char or String-String or 1-char-1-String or 1-String-1-char).
I would like to use the 1-char-1-String kind, but I get this compiler error message:
replace(char,char) in java.lang.String cannot be applied to (char,java.lang.String)
In my code I declared the variables before calling the method:
char this = 'x' ;
String that = "y" ;
I thought, with method overloading the compiler should
know which of the 4 methods has the matching parameters?
How can I reach the - well existing - method (char, String)?
Thanks for hinting me out of this!

juliane
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you're getting a message saying java.lang.String, that kind of tells me you're calling replace on the wrong object. I think you're looking for a Str object instead.
 
juliane gross
Ranch Hand
Posts: 161
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
right - that was the case..
thanx jason.

Juliane
[ July 08, 2003: Message edited by: juliane gross ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic