...
This function converts a string to a numeric value.
...
Are you interested in writing the conversion yourself, or do you just need the conversion to happen? These can help:Double.valueOf(String)Long.valueOf(String)
One approach would be to first try to convert the string to a long. If it works, then you have an integer. If it fails (i.e. throws an exception), then try to convert it to a double--maybe it was only a decimal point that caused the long conversion to fail. Success means it's a double, failure indicates a non-number string. After that, you'll have a long, a double or something that is neither, and you can do what you want with it.
...
please how to write the overload functions same parameter(passing only string) and returtype either double and long.
...
You're asking for something that doesn't exist. Parameters for overloaded methods must always be different (number or type of params), and the return type must always be the same. You'll have to come up with some other way to handle the multiple types.
gusano79
Practically a Master Poster
666 posts since May 2004
Reputation Points: 193
Solved Threads: 107
Skill Endorsements: 6