wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Method Overloading Examples Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Method Overloading Examples" Watch "Method Overloading Examples" New topic
Author

Method Overloading Examples

Dinakar Manchikalapudi
Greenhorn

Joined: Jan 28, 2007
Posts: 5
Can anyone explain what a method overloading is with the help of a simple example?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

Dinakar,
Welcome to JavaRanch!

Method overloading is when you have two or more methods with the same name and different arguments. There are many examples in articles on the subject. Do you have a more specific question on this?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Dinakar Manchikalapudi
Greenhorn

Joined: Jan 28, 2007
Posts: 5
Hii Jeanne,
Thanks for yr reply. I was looking for some sample code for overloaded methods. Does the overloaded method need to be in the same class?

Thanks,
Dinakar.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

I am moving this to the Java In General (Beginner) forum.

Thanks

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

Originally posted by Dinakar Manchikalapudi:
I was looking for some sample code for overloaded methods. Does the overloaded method need to be in the same class?

The article I linked to contains sample code. The overloaded method needs to be in the same class (or subclass). If they weren't, they would just be two methods that happened to have the same name.
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
Hi,

Method overloading is a method with same name but with different parameters. For eg


Corresponding method will be called based on parameters that you are passing. For eg, if you call add(3.0,5.0) in your program
double version of the add method will be invoked

i hope it helps you understand the overloading concepts.
Mostly overloading will be used in the same class.

bye for now
sat
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Method Overloading Examples
 
Similar Threads
overlading
method overriding
Function Overloading
java [question -- overloading]
Assigning default values to function arguments...possible in java ?