‎2007 Jun 29 11:51 AM
how can the phenomenon of method overloading achieved through optional,can any one explain in brief
‎2007 Jun 29 11:54 AM
Hi,
In method overloading what we do is We want to pass different INPUT's in each method.
SO what you do is Your create one method with IMPORT paramters that are most likely to be used.
Then you add more IMPORT paramters that will be used when you want to say process different type of data then make these paramters optional.
So in the method if the OPTIONAL paramters are passed process the optional parameters also else just process for the mandatory paramters.
Check if the OPTIONAL paramters is supplied using the key word SUPPLIED.
Do reward usful answers.
Regards,
Sesh
‎2007 Jul 02 12:22 PM
hi sandeep
Method Overloading
Method overloading is the ability to define several methods all with the same name. At first sight, that sounds stupid, but there are good reasons to want to. For example you are happy with the idea that ; that it is easy to treat a real number as a complex number. Suppose we wish to do so in our Complex class. It would seem natural to write a new add() method as follows:
Complex add(double x) {
return new Complex(this.x + x, y);
}
This is described by saying that the add() method has been overloaded. Although the name and return type are the same as the one used with a Complex argument, the arguments consist of different types and the JAVA compiler has no problem choosing the right one. We refer this combination of the number and types of arguments of a method as its signature. The combination of name and signature should be unique. Another example is the PrintStream class; you've seen that the print() and println() methods can take many different arguments.
Although you can overload methods, you can't overload operators: * and + can't be extended to work with matrices as they can in some other languages3.3. You have already seen the single exception to this: the + operator has been overloaded within JAVA for String concatenation.
‎2007 Jul 05 12:29 PM
Hi Sandeep,
Simply we can call as "same name with different Parameters".
For example, You have method called add(). In method overloading you can use the same mehod add() as
add(int a, int b) - Here add()method uses two parameters ie. int,int
add(int, float,float) - Here add() method uses three parameters ie.int,float,float.
Regards
shri