Data Types: Function Overloading using Data Types
public class functionOverLoadingDataTypes {
// func to cal int sum
public static int sum(int a, int b) {
return a + b;
}
// func to cal float sum
public static float sum(Float a, Float b) {
return a + b;
}
public static void main(String[] args) {
System.out.println(sum(10, 15));
System.out.println(sum(10.5f, 15.57f));
}
}
No comments:
Post a Comment