method over loading
Mon Jul 08 2024 16:09:35 GMT+0000 (Coordinated Universal Time)
Saved by
@signup
public class MyMath{
public static int add(int a, int b){
return a+b;
}
public static double add(double a, double b){
return a+b;
}
public static long add(long a,long b){
return a+b;
}
public static float add(float a,float b){
return a+b;
}
}
///
public class MyMathTest{
public static void main(String[] args){
System.out.println(MyMath.add(1,2));
System.out.println(MyMath.add(1234L,1432L));
System.out.println(MyMath.add(1.27,24.8));
System.out.println(MyMath.add(1.23F,1.45F));
}
}
content_copyCOPY
Comments