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


anita dhar
Ranch Hand

Joined: Jul 14, 2007
Posts: 69
Hello java ranchers,
I am confused with overloading ? can any one explain me this concept properly with example where we can go for overloading and where we are restricting

thanks in advance
ailina nagarawati

Joined: Jul 25, 2007
Posts: 4

overloading basically means you modify a method so that it can accept different arguments.. (arguments are the variables inside the bracket)

for example:
you have a method:

public void doSomething(int a, int b){}

if you overload it so that the method can accept "double type" arguments, you might have something like this:
public void doSomething(double a, double b){}

for more info:
Anurag Blore
Ranch Hand

Joined: Jan 15, 2003
Posts: 74
Please remember key points.

1. Overloading happens in a single CLASS

Other rules taken from Kathy Sierra book

Overloaded methods
Must have different argument lists
May have different return types, if argument lists are also different
May have different access modifiers
May throw different exceptions

SCJP 1.2 & 1.5, PMP
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Hi Anee,
My suggestion would be , you pick up some java book go through overloading and overriding concepts and then come back with specific doubts and we will be glad to answer them. This will only help you to understand the concept better so that you will remember them for a longer duration.
If you read them and try them you will find many small concepts hidden in them which i dont think will be covered over this forum.
I don't mean to offend its just a suggestion.
[ August 12, 2007: Message edited by: Deepak Jain ]

Mohammad Hossain

Joined: Jul 26, 2007
Posts: 14
Ya thats right.
I would suggest read some books, try some examples, find out some specific questions and post them here.
Because only a forum is not enough to explain overloading. There are many exceptions. And if people don't explain all of them to you. You will become more confused.
If that sounds offended I am really sorry for that. I just wanted to help.

Live Free Or Die
I agree. Here's the link:
subject: Overloading
It's not a secret anymore!