Function Overloading using Parameters, Java Programming Code
public class functionOverLoading {
// func to calc sum of 2 nums
public static int sum(int a, int b) {
return a + b;
}
// func to calc sum of 3 nums
public static int sum(int a, int b, int c) {
return a + b + c;
}
public static void main(String[] args) {
System.out.println(sum(5, 6));
System.out.println(sum(5, 7, 12));
}
}
No comments:
Post a Comment