Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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 The Software Craftsman this week in the Agile 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: 3881

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: 9327

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
Have you tried LearnNowOnline?
subject: Function Overloading..?