Sunday, June 14, 2020

Method OverLoading

Method OverLoading


Duplicate/Same  method names used or called multiple times with different arguments.


---> Sample Program


package programs;

public class MethodOverloading {

// method
public void method1(int a) {
System.out.println(a);
}

// method
public void method1(String a) {
System.out.println(a);
}

public static void main(String[] args) {
// TODO Auto-generated method stub

// creating object for MethodOverloading

MethodOverloading obj = new MethodOverloading();
    obj.method1(10);
    obj.method1("test");
}

}




i.e

i.argument count should be different.
ii.argument data type should be different.

No comments:

Post a Comment

Selenium_Grid_With_Docker_Compose(yml file)

 docker-compose.yml version: "3" services:   hub:     image: selenium/hub:3.141.59     ports:       - "4444:4444"   chro...