This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Function Overloading..?" Watch "Function Overloading..?" New topic

Function Overloading..?

Denis Dsouza

Joined: Apr 01, 2009
Posts: 2

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

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

Joined: Mar 24, 2008
Posts: 3815

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

Integer: 1
Double: 2.0

[How to ask questions] [Twitter]
Ankit Garg

Joined: Aug 03, 2008
Posts: 9291

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
Consider Paul's rocket mass heater.
subject: Function Overloading..?
Similar Threads
Why Below Code Is Compile And Executes Successfully.
Generic Program Warning
var-args and overloading
doubt in double and Integer