Method overloading is one of the most important feature of the java programming language. One method of achieving polymorphism in java through method overloading. Definition: Multiple occurrence of a method / function in a class with difference in parameter type and (or) difference in number of parameters is called method / function overloading. Consider the following example class OverloadTest { int a; String b; public void getValues() { a = 10; b = "no arguments"; } public void getValues(int a) { this.a = a; b = "with integer arguments"; } public void getValues(String b) { a = 20; this.b = b; } public void display() { System.out.println(b); System.out.println("Value of a ="+a); } } public class OverLoadDemo { ...
Computer Programming Video Tutorials