/*
method overloading means
*
*
* u can declare multiple functions/methods with the same name
*
* that functions must have different number/type of arguments
*/
class OverloadExample {
public void show() // First function
{
System.out.println("function with no argument");
}
public void show(int x) // second function
{
System.out.println("function with one argument");
}
public void show(int x, int y) // second function
{
System.out.println("function with two argument");
}
}
class MethodOverloading {
public static void main(String args[]) {
OverloadExample part= new OverloadExample();
part.show();
part.show(25);
part.show(25, 75);
OverloadExample mitesh = new OverloadExample();
mitesh.show();
}
}
method overloading means
*
*
* u can declare multiple functions/methods with the same name
*
* that functions must have different number/type of arguments
*/
class OverloadExample {
public void show() // First function
{
System.out.println("function with no argument");
}
public void show(int x) // second function
{
System.out.println("function with one argument");
}
public void show(int x, int y) // second function
{
System.out.println("function with two argument");
}
}
class MethodOverloading {
public static void main(String args[]) {
OverloadExample part= new OverloadExample();
part.show();
part.show(25);
part.show(25, 75);
OverloadExample mitesh = new OverloadExample();
mitesh.show();
}
}
0 comments:
Post a Comment