Example code for method overloading
package oops;
public class OverLoadingDemo {
public void m1()
{
System.out.println("no arg");
}
public void m1(int i)
{
System.out.println(" int arg");
}
public void m1(String i)
{
System.out.println(" String arg");
}
public static void main(String a[])
{
OverLoadingDemo s=new OverLoadingDemo();
s.m1();
s.m1(10);
s.m1("sun");
}
}
output:
no arg
int arg
String arg
0 comments:
Post a Comment