what is function overloading | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

what is function overloading

9th Sep 2016, 11:24 AM
Dhruv Thakur
Dhruv Thakur - avatar
3 Respuestas
+ 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); } }
9th Sep 2016, 11:36 AM
Zen
Zen - avatar
+ 1
same name of methods bt with dufferent parameters !! its method overloading or polymorphism !!
12th Sep 2016, 3:47 PM
Bhushan Gaikwad
Bhushan Gaikwad - avatar
0
thanks
9th Sep 2016, 11:31 AM
Dhruv Thakur
Dhruv Thakur - avatar