This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Function Overloading..? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Function Overloading..?" Watch "Function Overloading..?" New topic
Author

Function Overloading..?

Denis Dsouza
Greenhorn

Joined: Apr 01, 2009
Posts: 2
Hello,

Can any one help me understand why the output of the below always displays as

Double 1.0
Double 2.0




I tried to reorder the doSome functions, but always only the one with 'Double' parameter seems to execute.

Can anyone please let me know the logic behind this? Its driving me crazy..!
Denis Dsouza
Greenhorn

Joined: Apr 01, 2009
Posts: 2
Note: Assume the syntax & keywords are correct.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

Can you show us the output as it appears? This outputs

Integer: 1
Double: 2.0


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Vijitha is right. There is no way that the code can output Double both the times. Even if you try, you'll get a compilation error



SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Function Overloading..?
 
Similar Threads
doubt in double and Integer
Why Below Code Is Compile And Executes Successfully.
Generic Program Warning
Overloading
var-args and overloading