• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Overloading

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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:
http://java.ittoolbox.com/documents/popular-q-and-a/overloading-and-overriding-3699
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Thanks
Deepak
[ August 12, 2007: Message edited by: Deepak Jain ]
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Thanks
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic