Meaningless Drivel is fun!
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

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
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: 4541

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!