-
Notifications
You must be signed in to change notification settings - Fork 13
/
Example2.java
60 lines (47 loc) · 989 Bytes
/
Example2.java
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package lessons.methods.methodoverloading;
public class Example2 {
public static void main(String[] args)
{
// Over.foo(5, 5); -> Error: Ambiguous method call. Both
}
}
class Over {
public static void foo(long l, int i)
{
//...
}
public static void foo(int i, double d)
{
//...
}
public static void foo(float f, int i)
{
//...
}
}
class Calculator {
public long add(long a, long b)
{
return add(a, b, 0);
}
public long add(long a, long b, long c)
{
return add(a, b, c, 0);
}
public long add(long a, long b, long c, long d)
{
return a + b + c + d;
}
public double add(double a, double b)
{
return add(a, b, 0.);
}
public double add(double a, double b, double c)
{
return add(a, b, c, 0.);
}
public double add(double a, double b, double c, double d)
{
return a + b + c + d;
}
}