1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
package 控制语句;
public class TestOverload { public static void main(String[] args) { } public static int add(int n1,int n2) { int sum = n1+n2; return sum; } public static int add(int n1,int n2,int n3) { int sum = n1+n2+n3; return sum; } public static double add(double n1,int n2) { double sum = n1+n2; return sum; } public static double add(int n1,double n2) { double sum = n1+n2; return sum; }
}
|