The next day overloaded Java methods

// overloaded methods 
// the name of the same plurality of methods, but not the same as the argument list
public class Demo2 { public static void main (String [] args) { int A = 10 ; int B = 20 is ; Double C = 30 ; System.out.println(sum(b,c)); } public static int sum(int a,int b){ return a+b; } public static double sum(int a,double b){ return a+b; } public static double sum(double a,int b){ return a+b; } public static double sum(double a,double b){ return a+b; } }

 

Guess you like

Origin www.cnblogs.com/vxiao2/p/11478369.html