File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes overloading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "overloading" Watch "overloading" New topic


S Majumder
Ranch Hand

Joined: Jun 03, 2009
Posts: 346
Hi All,
I have one confusion about the overloading ...

Why this code is giving duplicate methods exception ?

Girish K Gupta

Joined: Mar 14, 2007
Posts: 19

Because for overloading the method arguments MUST be different.

Girish K Gupta
SCJP 1.5 - 87%, SCWCD 1.5 - 92%
John Jai

Joined: May 31, 2011
Posts: 1776
Because overloading methods need to be different in their parameter list. Different return types alone doesn't make a method different from one another. Read more here
Matthew Brown

Joined: Apr 06, 2010
Posts: 4543

Remember that you don't have to do anything with return values - it's allowable to ignore them. So if you went
Which one gets called? The compiler can't tell.
I agree. Here's the link:
subject: overloading
It's not a secret anymore!