Java Overloading
Method Overloading
Two or more methods have the same name but different parameters are called Method overloading.
Syntax:
class A { void show(int a) { //body of the method. } void show(int a, int b) { //body of the method. } }

Example:
class A { void show(int a) { System.out.println("Area of square: "+(a*a)); } void show(int a, int b) { System.out.println("Area of Rectangle: "+(a*b)); } } public class Methodoverloading{ public static void main(String args[]) { A a=new A(); a.show(5); a.show(5,7); } }
Quickly Find What You Are Looking For
Onlinetpoint is optimized for basic learning, practice and more. Examples are well checked and working examples available on this website but we can't give assurity for 100% correctness of all the content. This site under copyright content belongs to Onlinetpoint. You agree to have read and accepted our terms of use, cookie and privacy policy.