jQuery in Action, 3rd edition
The moose likes Cattle Drive and the fly likes method overloading ??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "method overloading ???" Watch "method overloading ???" New topic

method overloading ???

juliane gross
Ranch Hand

Joined: May 30, 2002
Posts: 161
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!

jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
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

Joined: May 30, 2002
Posts: 161
right - that was the case..
thanx jason.

[ July 08, 2003: Message edited by: juliane gross ]
I agree. Here's the link: http://aspose.com/file-tools
subject: method overloading ???
It's not a secret anymore!