package LearnJava;
public class TestMethodOverLoadingExample1 {
public void add(int p, int m) {
System.out.println("I am method with integre argument");
System.out.println(p + m);
}
public void add(double p, double m) {
System.out.println("I am method with double argument");
System.out.println(p + m);
}
public void add(float p, float m) {
System.out.println("I am method with float argument");
System.out.println(p + m);
}
public float add(int i, long p){
System.out.println("I am from method where return type is integer");
return p;
}
public boolean add(boolean i, boolean p){
System.out.println("I am from method where return type is boolean");
return true;
}
public static void main(String args[]) {
TestMethodOverLoadingExample1 obj = new TestMethodOverLoadingExample1();
obj.add(20.5, 21.5);
obj.add(20f, 20f);
obj.add(20, 20);
obj.add(8, 90L);
obj.add(false, true);
}
}
public class TestMethodOverLoadingExample1 {
public void add(int p, int m) {
System.out.println("I am method with integre argument");
System.out.println(p + m);
}
public void add(double p, double m) {
System.out.println("I am method with double argument");
System.out.println(p + m);
}
public void add(float p, float m) {
System.out.println("I am method with float argument");
System.out.println(p + m);
}
public float add(int i, long p){
System.out.println("I am from method where return type is integer");
return p;
}
public boolean add(boolean i, boolean p){
System.out.println("I am from method where return type is boolean");
return true;
}
public static void main(String args[]) {
TestMethodOverLoadingExample1 obj = new TestMethodOverLoadingExample1();
obj.add(20.5, 21.5);
obj.add(20f, 20f);
obj.add(20, 20);
obj.add(8, 90L);
obj.add(false, true);
}
}
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleteCore Java Training in Electronic city