0
what is function overloading
3 odpowiedzi
+ 2
Function overloading is when you define several methods with the same name and return value but different parameters. When you then use the method, the corresponding method will be called depending on the parameters used.
Example:
http://code.sololearn.com/ctq7mDAWV97T
class A
{
public void doStuff(int n)
{
System.out.println("Working with the int " + n + "!");
}
public void doStuff(double d)
{
System.out.println("Working with the double " + d + "!");
}
}
public class Program
{
public static void main(String[] args) {
A a = new A();
a.doStuff(3);
a.doStuff(3.0);
}
}
+ 1
same name of methods bt with dufferent parameters !! its method overloading or polymorphism !!
0
thanks